Tutorial by Examples: broadcastreceiver

A Broadcast receiver is an Android component which allows you to register for system or application events. A receiver can be registered via the AndroidManifest.xml file or dynamically via the Context.registerReceiver() method. public class MyReceiver extends BroadcastReceiver { @Override ...
BroadcastReceivers are used to receive broadcast Intents that are sent by the Android OS, other apps, or within the same app. Each Intent is created with an Intent Filter, which requires a String action. Additional information can be configured in the Intent. Likewise, BroadcastReceivers register ...
add permission in your manifest file <uses-permission android:name="android.permission.BLUETOOTH" /> In your Fragment(or Activity) Add the receiver method private BroadcastReceiver mBluetoothStatusChangedReceiver = new BroadcastReceiver() { @Override public void o...
To enable or disable a BroadcastReceiver, we need to get a reference to the PackageManager and we need a ComponentName object containing the class of the receiver we want to enable/disable: ComponentName componentName = new ComponentName(context, MyBroadcastReceiver.class); PackageManager packageM...
Example below shows how to create a BroadcastReceiver which is able to receive BOOT_COMPLETED events. This way, you are able to start a Service or start an Activity as soon device was powered up. Also, you can use BOOT_COMPLETED events to restore your alarms since they are destroyed when device is ...
You can communicate two activities so that Activity A can be notified of an event happening in Activity B. Activity A final String eventName = "your.package.goes.here.EVENT"; @Override protected void onCreate(Bundle savedInstanceState) { registerEventReceiver(); super.onCre...
First create a BroadcastReceiver class to handle the incoming Location updates: public class LocationReceiver extends BroadcastReceiver implements Constants { @Override public void onReceive(Context context, Intent intent) { if (LocationResult.hasResult(intent)) { ...

Page 1 of 1