Mobilock app starts before BOOT_COMPLETED broadcast… How is it possible?

跟風遠走 提交于 2019-12-01 11:01:00

Listen also to android.intent.action.QUICKBOOT_POWERON and android.intent.action.LOCKED_BOOT_COMPLETED.

It seems to be device-dependant, which broadcast is sent first.

Oh my god! I've luckily found it. :)

This Page Says : Apps must register their components with the system before they can run during Direct Boot mode or access device encrypted storage. Apps register with the system by marking components as encryption aware. To mark your component as encryption aware, set the android:directBootAware attribute to true in your manifest.

Encryption aware components can register to receive a ACTION_LOCKED_BOOT_COMPLETED broadcast message from the system when the device has been restarted. At this point device encrypted storage is available, and your component can execute tasks that need to be run during Direct Boot mode, such as triggering a scheduled alarm.

You just need to put

android:directBootAware="true"

So the code in manifest is;

<receiver
  android:directBootAware="true" >
  ...
 <intent-filter>
  <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
 </intent-filter>
</receiver>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!