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

后端 未结 2 963
北恋
北恋 2021-01-15 15:41

There is a kiosk app called Mobilock. This app starts way faster (Almost 5 seconds before) than my own app which starts with BOOT_COMPLETED broadcast.

My own app has

相关标签:
2条回答
  • 2021-01-15 16:13

    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.

    0 讨论(0)
  • 2021-01-15 16:16

    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>
    
    0 讨论(0)
提交回复
热议问题