If I declare BroadcastReceiver
through the mainfest file for system broadcasting (say, for example ACTION_POWER_DISCONNECTED
), the system will call it every time a particular broadcast is sent, so the BroadcastReceiver's lifetime is unlimited.
But there are also broadcasts that cannot be registered through the manifest file. For these broadcasts, we must call context.registerReceiver
with the appropriate IntentFilter
. Let's say I create a BroadcastReceiver for BOOT_COMPLETED
and call context.registerReceiver
from it and never call unregisterReceiver
Does this receiver support forever (before rebooting the phone)?
Applications targeting Android O can no longer register broadcast receivers for implicit transmissions in their manifest. Implicit casting is a broadcast that is not specifically designed for this application.
If my top hypothesis is correct, this would be an easy workaround to change the system (of course, you should not do it this way, but that would be possible). So, BroadcastReceiver
registered after the broadcast BOOT_COMPLETED
has the same lifetime (remains until the next reboot) as a BroadcastReceiver, which is automatically registered through the manifest?
source
share