package com.xixun.display;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.app.ActivityCompat;
import android.util.Log;

import com.xixun.communicate.ClientsManage;
import com.xixun.communicate.Define;
import com.xixun.communicate.LedCardCommunication;
import com.xixun.communicate.WorkParams;
import com.xixun.joey.uart.IUartService;
import com.xixun.util.PlayerInfo;
import java.io.Closeable;
import java.io.File;
import static java.lang.Thread.sleep;


@SuppressLint("NewApi")

public class MainActivity extends Activity{
     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         //动态申请权限
         verifyStoragePermissions(this);
        Log.i("_yzd", "start display activity");
        Intent autoRun = new Intent(this, MyService.class);
        startService(autoRun);
        finish();
        Log.i("_yzd", "finish display activity");

         /*Intent aidl = new Intent(this, AIDLService.class);
         startService(aidl);
         finish();*/
    }
    // Storage Permissions
    private static final int REQUEST_EXTERNAL_STORAGE = 1;
    private static String[] PERMISSIONS_STORAGE = {Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE };

    /**
     * 动态申请权限
     * @param activity
     */
    public static void verifyStoragePermissions(Activity activity) {
        // Check if we have write permission
        int permission = ActivityCompat.checkSelfPermission(activity,
                Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (permission != PackageManager.PERMISSION_GRANTED) {
            // We don't have permission so prompt the user
            ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
                    REQUEST_EXTERNAL_STORAGE);
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}


