22 lines
652 B
Kotlin
22 lines
652 B
Kotlin
package com.sw.inbound.receiver
|
|
|
|
import android.content.BroadcastReceiver
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import com.sw.inbound.MainActivity
|
|
import timber.log.Timber
|
|
|
|
/**
|
|
* 开机广播监听
|
|
*/
|
|
class BootReceiver : BroadcastReceiver() {
|
|
|
|
override fun onReceive(context: Context, intent: Intent) {
|
|
if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
|
|
Timber.d("设备启动完成,开始执行自启动逻辑")
|
|
val intent = Intent(context, MainActivity::class.java)
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
context.startActivity(intent)
|
|
}
|
|
}
|
|
} |