BroadcastReceiver Lifetime for Android O Changes

If I declare BroadcastReceiverthrough 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.registerReceiverwith the appropriate IntentFilter. Let's say I create a BroadcastReceiver for BOOT_COMPLETEDand call context.registerReceiverfrom it and never call unregisterReceiverDoes 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, BroadcastReceiverregistered after the broadcast BOOT_COMPLETEDhas the same lifetime (remains until the next reboot) as a BroadcastReceiver, which is automatically registered through the manifest?

+6
source share
1 answer

, BroadcastReceiver BOOT_COMPLETED context.registerReceiver unregisterReceiver, ( )?

-, BOOT_COMPLETED , - , , , "O" .

( ), . , .

, BroadcastReceiver, BOOT_COMPLETED, ( ) BroadcastReceiver, ?

, , - - . ( Android) .

Nasir Khan .

+8

Source: https://habr.com/ru/post/1016185/


All Articles