Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has requestCode in PendingIntent always been supported?

I'm trying to distinguish between different instances of PendingIntent by having separate requestCode for each use-case as suggested by this earlier question.

Is this a robust solution? Has requestCode always been supported even though the javadocs still say that it is "currently not used"?

like image 897
Hrushikesh Avatar asked Sep 08 '12 19:09

Hrushikesh


People also ask

What is requestCode in PendingIntent?

requestCode is used to retrieve the same pending intent instance later on (for cancelling, etc).

What is PendingIntent Flag_one_shot?

FLAG_ONE_SHOT. Flag indicating that this PendingIntent can be used only once. int. FLAG_UPDATE_CURRENT. Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent.

What is the difference between intent and PendingIntent?

In conclusion, the general and main difference between Intent and PendingIntent is that by using the first, you want to start / launch / execute something NOW, while by using the second entity you want to execute that something in the future.

What is an android PendingIntent?

Android PendingIntent In other words, PendingIntent lets us pass a future Intent to another application and allow that application to execute that Intent as if it had the same permissions as our application, whether or not our application is still around when the Intent is eventually invoked.


1 Answers

Yes. The requestCode has always been there. It isn't currently used by the Android framework to do anything other than as part of the test for PendingIntent matching. Using requestCode to determine different PendingIntents is robust and supported. The documentation even says so:

  • If you truly need multiple distinct PendingIntent objects active at the same time (such as to use as two notifications that are both shown at the same time), then you will need to ensure there is something that is different about them to associate them with different PendingIntents. This may be any of the Intent attributes considered by Intent.filterEquals, or different request code integers supplied to getActivity(Context, int, Intent, int), getActivities(Context, int, Intent[], int), getBroadcast(Context, int, Intent, int), or getService(Context, int, Intent, int).
like image 61
David Wasser Avatar answered Oct 18 '22 05:10

David Wasser