一定是在mainfest静态声明
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
恢复出厂设置后开机启动
android.intent.action.PRE_BOOT_COMPLETED
开机完锁屏时启动
<receiver
android:name=".receivers.BootCompletedReceiver"
android:directBootAware="true"
android:encryptionAware="true"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>
解锁后启动
BOOT_COMPLETED
参考: