Reputation: 31
When users enters and date and time it then puts it into alarm manager
public Manager(Context context){
mContext = context;
tolarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
}
public void setSilent(Long id, Calendar when){
Intent go = new Intent(mContext, someclass.class);
PendingIntent golow = PendingIntent.getBroadcast(mContext, 0 , i, PendingIntent.FLAG_ONE_SHOT);
toAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), golow);
when the alarm is set how do i delete it from the alarm if i dont want alarm any more?
Upvotes: 0
Views: 557
Reputation: 740
int RC = alarmRequestCode; // your request code is 0
Intent intentAlarm = new Intent(context, AlarmReciever.class);
PendingIntent sender = PendingIntent.getBroadcast(context, RC, intentAlarm, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
alarmManager.cancel(sender);
Upvotes: 2
Reputation: 6167
You do
toAlarmManager.cancel(golow);
which removes any alarms with the matching intent.
Upvotes: 0