当用户输入日期和时间时,将其放入警报管理器
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);
当设置闹钟时,如果我不再需要闹钟,如何将其从闹钟中删除?
答案 0 :(得分:3)
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);
答案 1 :(得分:0)
你做
toAlarmManager.cancel(golow);
删除任何具有匹配意图的警报。