Create new Pending Intent every time in Android

android, android-pendingintent

Solution

add a random number to the request code like that:

Intent intent = new Intent(context, YourClassname.class);
intent.putExtra("some data", "txt");  // for extra data if needed..

Random generator = new Random();

PendingIntent i=PendingIntent.getActivity(context, generator.nextInt(), intent,PendingIntent.FLAG_UPDATE_CURRENT);

Problem

How do I create a pending intent everytime? Currently my existing pending intent is getting replaced with a new one. I tried using `FLAG_ONE_SHOT` as well as `CANCEL_CURRENT` but it didn't work.

Original source