package com.siwei.recyclebox.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;

import com.siwei.recyclebox.ui.main.MainActivity;

public class BootReceiver extends BroadcastReceiver {
    private static final String TAG = "BootReceiver";

    /*
    * 广播监听开机，开机就启动app；开机时网络可能要等会儿才能识别到，所以延迟启动
    * */
    @Override
    public void onReceive(Context context, Intent intent) {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Log.e(TAG,"onReceive//////////////////:"+intent);
                Intent i = new Intent(context,MainActivity.class);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                context.startActivity(i);
            }
        },60000);

    }
    public android.os.Handler mHandler = new Handler(msg -> {
        return true;
    });
}
