How can I setup multiple alarms in Android?

Ok, when you set an PendingIntent, you’re supposed to assign it a unique ID to it, incase you want to identify it later (for modifying/canceling it)

static PendingIntent    getActivity(Context context, int requestCode, Intent intent, int flags) 
//Retrieve a PendingIntent that will start a new activity, like calling Context.startActivity(Intent).
static PendingIntent    getBroadcast(Context context, int requestCode, Intent intent, int flags) 
//Retrieve a PendingIntent that will perform a broadcast, like calling Context.sendBroadcast().

The Request code is that ID.

In your code, you keep resetting the SAME PendingIntent, instead use a different RequestCode each time.

PendingIntent pIntent = PendingIntent.getActivity(context,uniqueRQCODE, newIntent, 0);

It has to be an integer, i suppose you have a primaryid (itemId) that can identify Alarm A from Alarm B.

Leave a Comment