In my code, i am creating various PendingIntent objects using getBroadcast().
My application needs to represent a few different types of PendingIntents, and for this reason i create the underlying Intent with a different action string (unique per PendingIntent).
My question is - does it make any difference to differentiate the pending intents by the request code, or stick with the technique i am doing now ?
Example:
What i'm doing now:
Intent intent = new Intent(Receiver.class);
intent.setAction("unique.name.here");
PendingIntent.getBroadcast(this, 0, intent, flags);
Other technique:
Intent intent = new Intent(Receiver.class);
PendingIntnt.getBroadcast(this, uniqueId, intent, flags);
Is there any reason why should i pick one technique over the other?
Use whatever technique you want that works for you. Sometimes you need a unique PendingIntent but you can't use a unique action because the action is used for some other purpose (Intent resolution or whatever).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With