If I declare a BroadcastReceiver
via the mainfest file for a system broadcast (let's say for example ACTION_POWER_DISCONNECTED
) the the system will call it every time the specific broadcast is send so the lifetime of the BroadcastReceiver is unrestricted.
But there are also broadcasts which can not be registered via the manifest file. For these broadcasts we have to call context.registerReceiver
with a corresponding IntentFilter
. Let's say I create a BroadcastReceiver for BOOT_COMPLETED
and call context.registerReceiver
from it and never call unregisterReceiver
does this receiver also lives forever (until the phone is rebooted)?
Apps that target Android O can no longer register broadcast receivers for implicit broadcasts in their manifest. An implicit broadcast is a broadcast that does not target that app specifically.
If my conjecture from above is right this would be an easy workaround for the system change (of course you shouldn't do it this way but it would be possible). So does a BroadcastReceiver
which is registered after a BOOT_COMPLETED
broadcast have the same lifetime (stays until the next reboot) as a BroadcastReceiver which is automatically registered via the manifest?