I have an activity (setting alarm) that creates a repeating alarm, I need to cancel that alarm from another activity (cancel alarm). I am unable to cancel the alarm. What am I doing wrong?:
public class settingalarm...
am =(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent alrm = new Intent(context, z.class);
alrm.setAction(ALARM);
alrm.putExtra(x, x);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, alrm, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, 0, 30000, alarmIntent);
I have another activity that needs to cancel the existing alarm:
public class cancelingalarm...
am =(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent alrm = new Intent(context, z.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, alrm, 0);
am.cancel(alarmIntent);
Thanks in advance!