package com.jld.face.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.jld.vod.view.SplashActivity

/**
 * @author ZhaoFuXin
 * @Email：18276061387@163.com
 * @description:开机自启广播
 * @date :2020/4/22 17:25
 */
class BootBroadcastReceiver : BroadcastReceiver() {
    private val TAG:String ="BootBroadcastReceiver"
    private val ACTION:String = "android.intent.action.BOOT_COMPLETED"

    override fun onReceive(context: Context?, intent: Intent?) {
        var action = intent!!.action
        if (action.equals(ACTION)){
                var launchIntent =  Intent(context, SplashActivity::class.java)//重新启动应用
                //此处如果不想写死启动的Activity，也可以通过如下方法获取默认的启动Activity
               // val launchIntent = context!!.getPackageManager().getLaunchIntentForPackage(packageName);
//                launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
//                context!!.startActivity(launchIntent)
        }
    }
}