.........
class BOOTReceiver : BroadcastReceiver() {
val TAG = "mytag"
class ReceiverTimer {}
companion object {
//开机广播
val device_start_cation = "android.intent.action.BOOT_COMPLETED"
}
override fun onReceive(context: Context?, intent: Intent?) {
Log.i(TAG, "device start")
if (device_start_cation == intent?.action) {
//设备启动
}
}
}
测试是在Android7.1.1,先打开一次,在重启设备,开机广播接收成功。