2012-04-19 47 views
0

這裏的源代碼........如何停止報警運行ant控制

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()); 

回答

0

調用cancel方法與此掛起的意圖:

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

感謝您的答覆..我試過了,但沒有奏效。 – 2012-04-21 00:59:23