I am trying to understand the main differences between registering a BroadcastReceiver in the Manifest and registering it programmatically...
My understanding is basically as follows (would appreciate someone correcting my points if I am missing something).
Registered in Manifest:
Registered Programmatically:
thanks
A Service receives intents that were sent specifically to your application, just like an Activity. A Broadcast Receiver receives intents that were broadcast system-wide to all apps installed on the device.
The main difference in working between the static and dynamic receivers is that the static receivers will run if the application is running/not running. But the dynamic receivers will run if the application is running.
An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest. xml file. Consider we are going to register MyReceiver for system generated event ACTION_BOOT_COMPLETED which is fired by the system once the Android system has completed the boot process.
You have it basically correct.
Note that a manifest-registered receiver object is only used once. A new instance of your BroadcastReceiver
is created for each broadcast. The primary use of manifest-registered receivers is for broadcasts that may go on while your code is not in memory (e.g., BOOT_COMPLETED
, your scheduled alarms via AlarmManager
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With