Tuesday, 23 March 2021

After device restart, my app receiving BOOT_COMPLETED broadcast slower/later than other apps?

When I restart my device, I am receiving BOOT_COMPLETED broadcast much slower (around 10-15 seconds later) than other apps.

I have seen this. But I do not think this is completely true. How (I think) I proved it wrong:

(Let's define X as an application that receives BOOT_COMPLETED broadcast faster than mine).

  1. Installed X
  2. Installed my application.
  3. Restarted device.

RESULT: X received BOOT_COMPLETED broadcast very fast. My applicated received the broadcast slow.

  1. Uninstalled both applications.
  2. Installed my application once again.
  3. Restarted device.

RESULT: My app received BOOT_COMPLETED broadcast slow again.

  1. Uninstalled my application.
  2. Installed X.
  3. Restarted device.

RESULT: X received BOOT_COMPLETED broadcast very fast once again.

CONCLUSION: My app receives BOOT_COMPLETED broadcast slow whether X is installed or not. X always receives BOOT_COMPLETED broadcast very fast. How X is being able to receive the boot completed broadcast much faster than my application even though X is installed after my application?

That is why I do not think this is completely true answer. There is something X is doing that causing it to receive BOOT_COMPLETED at a higher priority than my app.

Maybe there are some other broadcasts other than BOOT_COMPLETED which are much faster?

Any suggestions are appreciated.

Manifest:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
...
<receiver 
    android:name=".receivers.BootCompletedIntentReceived">
    <intent-filter android:priority="2147483647">
        <category android:name="android.intent.category.DEFAULT"/>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
        <!--For HTC devices-->
        <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
    </intent-filter>
</receiver>

BootCompletedIntentReceived.kt

class BootCompletedIntentReceived: BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        //DO SOMETHING HERE
    }
}


from After device restart, my app receiving BOOT_COMPLETED broadcast slower/later than other apps?

No comments:

Post a Comment