package com.hh.hhomc.broadreceiver;

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

import com.common.lib_base.utils.log.AppLogUtils;
import com.hh.hhomc.BackgroundActivity;
import com.hh.hhomc.MainActivity;
import com.hh.hhomc.services.BackgroundService;

public class AutoStartBroadReceiver extends BroadcastReceiver {
    private static final String ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        AppLogUtils.e("接收广播", "onReceive: ");
        AppLogUtils.e("接收广播", "onReceive: " + intent.getAction());
        //开机启动
        if (ACTION.equals(intent.getAction())) {
            AppLogUtils.e("接收广播", "onReceive: 启动了。。。");

            Intent mainIntent = new Intent(context, BackgroundActivity.class);
            /**
             * Intent.FLAG_ACTIVITY_NEW_TASK
             * Intent.FLAG_ACTIVITY_CLEAR_TOP
             */
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);
        }
    }

}