Registering BOOT_COMPLETED receiver in Android 8

9.9k Views Asked by At

We are about to update our App Android API 26. In the documentation about Broadcast receiver it says that

Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest

Implicit broadcast receivers are described as

a broadcast that does not target that app specifically. For example, ACTION_PACKAGE_REPLACED

So I assume that android.intent.action.BOOT_COMPLETED is considered an implicit receiver.

Further it states that implicit receivers must be registered within an Activity by using Context.registerReceiver(). But that wouldn't make sense for a receiver, which is listening for the BOOT_COMPLETED event.

What is the proper way to handle this? Can i keep this receiver in my manifest?

2

There are 2 best solutions below

1
On BEST ANSWER

BOOT_COMPLETED is still accepted.

https://developer.android.com/guide/components/broadcast-exceptions.html

No need to change anything. Make sure you test in Android 8.

7
On

ACTION_BOOT_COMPLETED is on the implicit broadcast whitelist, and so you can register for it in the manifest.