Broadcast Are such classes in android by which data can be transferred bwetween several app also some triggers can be developed to execute some functions.
For Example
We can run our own methods when an android phone starts or whenever there is incoming call acutually we can say they are triggers for a code to be executed when a specified intent is alive inside the android operating system
<intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"> </action> </intent-filter>
the above intent can be declared in MANIFEST File and A broadcast Reciever onRecieve Method is executed whenever this intent is recieved
CUSTOM INTENTS IN ANDROID
you can create custombroadcast intent tha twhen on recieve will execute functions
public void broadcastIntent(View view){ Intent intent = new Intent(); intent.setAction("com.tutorialspoint.CUSTOM_INTENT"); sendBroadcast(intent); }
Include above code in your mainactivity on a button click this will send a broadcast intent and can be recieve via create reciever and declaring in manifest
No comments:
Post a Comment