Tuesday, January 10, 2017
Android Broadcast Receiver Tutorial
Android Broadcast Receiver Tutorial
Hello friends.
I hope my last tutorial will be helpful for you.
Today i am going to post all about Broadcast Receiver in Android.So going through this post you will be able to understand all about broadcast in android.
So extend BroadcastReceiver in the class to which you want to make receiver class and which is registered as a receiver in an Android Application via the AndroidManifest.xml file(or via code).This class will be able to receive intents. Intents can be generated via the Context.sendBroadcast() method. The class BroadcastReceiver defines the method onReceive() . Only during this method your broadcast receiver object will be valid, afterwards the Android system will consider your object as no longer active. Therefore you cannot perform any asynchronous operation.
We will define a broadcast receiver which listens to airplane mode changes. If the airplane mode changes then our receiver will be notified and toast a message.
- Create a new project "com.bp.broadcastdemo". We do not need an activity. Create the following "AndroidManifest.xml".