Search code examples
androidandroid-pendingintent

Multiple Pending Intents?


My activity creates a couple of notifications.

Here's how I'm currently doing it, on different resultIntents:

PendingIntent resultPendingIntent =
  PendingIntent.getActivity(
    context,
    0,
    resultIntent,
    PendingIntent.FLAG_UPDATE_CURRENT
  );

Now, since a flag is compulsory, I'm forced to select from the four flags. What do I do if I want all of them to work independently, and the newer notification isn't affected by the previous one.


Solution

  • A solution was found here: here.

    You've to use setAction on the intent to a unique value so that there will be no matching PendingIntents

    Here's what I used:

    setAction(Long.toString(System.currentTimeMillis()))