3
可能重複:
Why is my android alarm manager firing instantly?設置時間報警經理的Android - 報警立即解僱
我有這樣的代碼,將調用報警通知
public static Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.add(Calendar.HOUR_OF_DAY,hour);
cal.add(Calendar.MINUTE, min);
Intent intent = new Intent(this, OnetimeAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, REQUEST_CODE, intent,0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis() , pendingIntent);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
但警報立刻被觸發,它在給定的小時和分鐘後等待嗎? 應該向清單文件添加任何內容嗎?
我希望它在「小時」和「分鐘」之後被解僱,你可以看到cal.add(Calendar.HOUR_OF_DAY,hour); cal.add(Calendar.MINUTE,min); //小時將是例如5分鐘將是30,但它不工作! – 2010-10-23 18:45:08
然後顯示您設置小時和分鐘變量的代碼 – RoflcoptrException 2010-10-24 10:25:53