如何停止运行蚂蚁控制的警报

时间:2012-04-19 17:47:10

标签: android android-alarms

源代码在这里........

pendingIntent = PendingIntent.getBroadcast(AlarmAppActivity.this, 0, myIntent,PendingIntent.FLAG_ONE_SHOT );
                  //Intent myIntent = new Intent(AlarmAppActivity.this, AlarmService.class);
               //   PendingIntent pendingIntent = PendingIntent.getService(AlarmAppActivity.this, 0, myIntent, 0);


Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getDefault());
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, 0);
System.out.println("in   alendar.set(Calendar.HOUR_OF_DAY "+Calendar.HOUR_OF_DAY);
// calendar.setTimeInMillis(hour);
                            //calendar.setTimeInMillis(System.currentTimeMillis());
// calendar.add(Calendar.SECOND, 10);

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
System.out.println("in   alarmManager.set(AlarmMana) "+calendar.getTimeInMillis());

1 个答案:

答案 0 :(得分:0)

使用此待处理意图调用cancel方法:

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.cancel(pendingIntent);