Course Content

Course Content


How to create Intent and Broadcast Receiver component with an example in Android




The basic function of Intent is to pass messages between Android components, such as activities, content provider, services, broadcast receiver, etc ...


The dictionary meaning of 'Intent' is intention or purpose so it can be described as the intention to do action.


Android Intents are mainly used to :

  • Start the Service.
  • Display a Web Page.
  • Display a List of Contacts.
  • Dial a Phone Call etc.

As an example, we take a phone call, if I have to call someone, my most basic activity would be to open the dialer first, and then dial the phone number, as soon as I click on the call button then Intent will start calling from the particular application of calling. This means that Intent calling and Dialer communication was done here, and the task of calling has being achieved. Precisely, Dialer is the primary activity from which we will call and Calling is secondary activity.


Android Broadcast Receiver


The next component now is a Android Broadcast Receiver. Notification is a very common thing that keeps on coming in our mobile phones throughout the day, such as messages coming in, WiFi connected or disconnected, everything that happens is nothing but a broadcast receiving.


How Broadcast Receiver works ?

  •  Broadcast receiver is temporarily inactive component.
  • This activates when we register it for an intent.

Suppose we have created an intent in which we have written the code for wifi activation, and we have said that as soon as wifi comes our intent will run and it will tell that wifi is activated, and when I am turning off wifi immediately I get the notification that the wifi is deactivated. That is, here we have kept that Intent registered, for activation and deactivation of wifi.


Creating the Broadcast Receiver


Public class My Receiver extends Broadcast Receiver.


                @Override public void on Receiver(Context context, Intent intent)


                                Toast.makeText(context, intent Detected.”,





Here at first we have an Intent registered and as soon as that event is performed we will get the notification, now for this we take example of 'Truecaller' application, which is a very common application. Suppose there is a number and I want to block it, then we will go to the Truecaller application and activate that number in the block option, that is, here we have first registered an Intent that we can say we blocked the number, now as soon as that particular call comes to my Android system, then the intent of the Truecaller that has been registered will occur, and immediately we will get a notification that we received a call from this number and that number is now blocked.


Now we will see the second example of broadcast receiver, such as Battery, where we have made the Intent that the notification of battery low will be immediately visible on our mobile screen as soon as the battery is low.


Next example, suppose I have to go to some social gathering, then in the 'Remainder' application we can register our intent and as soon as the time comes, it will give us notification of it.


Broadcast receivers have many of examples, such as message notifications, and lots of real-time examples.


System Broadcasts





Boot completed requires the Android. RECEIVE_BOOT_COMPLETED permission.


Power got connected to the device.


Power got disconnected to the device.


Triggered low battery, typically used to reduce activities in your app which consume power.


Battery status good again.


So here we learn about the How to create Intent and Broadcast Receiver component and Now we take broadcast receiver example for better understanding


Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
297K+ Downloads
App Download Section Circle 1
4.5 Rating
App Download Section Circle 2
10K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere