Broadcast Receiver in Android

Broadcast Receiver Demo in android, Broadcast Receiver in android example

A broadcast receiver (short receiver) is an Android component which allows you to register for system or application events. All registered receivers for an event are notified by the Android runtime once this event happens. For example, applications can register for the ACTION_BOOT_COMPLETED system event which is fired once the Android system has completed the boot process.

We can create BroadcastReceiver in 2 ways :-

  1) Static Broadcast Receiver : Generally we create broadcast receivers in manifest file with a receiver tag. This is static way.
  2) Dynamic Broadcast Receiver The receiver created directly using android code without any tag in the manifest file.

For Static BroadcastReceiver we have to define its in AndroidMenifiest.xml file like this :

in tag
And for Dynamic BroadcastReciever we have to define using java code like this:
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.example.climbachiya.DYNAMIC_BROADCAST");

receiver = new MyBroadcastReceiver();



Check out the full demo here : https://github.com/CDL24/BroadcasrReceiverDemo

Just download and import full android studio project.

And if you like my efforts please share the blog and hits like Happy Coding ;)

Comments