Category : broadcastreceiver

I’m using an intent chooser and I need to know which one of the available apps is selected. To do so, in my activity I create the intent chooser like this: List<Intent> targetedShareIntents = new ArrayList<>(); targetedShareIntents.add(intent1); targetedShareIntents.add(intent2); Intent receiver = new Intent(this, BReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, receiver, PendingIntent.FLAG_UPDATE_CURRENT); Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), ..

Read more

#this method is used trigger the pending intents using alarm manager with different id’s#i just want create pending intent for each id after 30 sec i want cancel the trigger id# int bulletin id =1,2,3,4,5,6,7(the id’s will get dynamically from api not hardcoded so it can be 1 to 100);` public void setOk(Context context, int ..

Read more

BootReceiver.kt override fun onReceive(context: Context, intent: Intent) { if (intent.action == Intent.ACTION_BOOT_COMPLETED) { for (i in 0 .. 10) { Toast.makeText(context, "number $i", Toast.LENGTH_SHORT).show() Thread.sleep(1000) } } } Manifest.xml <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application> <receiver android:name=".BootReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application> If the mobile phone is rebooted in the above code, the for loop ..

Read more

I have gone trough several resources which deal with this problem, but none with a satisfactory explanation or solution. Some of the content I have gone through are: Broadcast receiver called 2 times when turning off GPS? My BroadcastReceiver is called two times when turning on/off wifi or gps? android.location.PROVIDERS_CHANGED BroadcastReceiver fires off many times ..

Read more

I would like to send out an Intent to 2 BroadcastReceivers, A and B in which A receives the Intent before B. It appears to me that the order the BroadcastReceivers are registered is the order that they will receive the Intent. For example: registerReceiver(A, filter); registerReceiver(B, filter); Will this cause A to receive the ..

Read more