我使用AlarmManager.i在android中编写了调度程序。使用以下方法启动警报。
AlarmManager manager = (AlarmManager) getApplicationContext()
.getSystemService(Context.ALARM_SERVICE);
int interval = 1000 * 60 * initailDelay;
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), interval, pendingIntent);
Toast.makeText(getApplicationContext(), "Alarm Set", Toast.LENGTH_SHORT)
.show();
现在我想在给定时间停止闹钟?例如我必须在6点开始闹钟并在6.30结束闹钟。
答案 0 :(得分:0)
添加以下行:
AlarmManager manager = (AlarmManager) getApplicationContext()
.getSystemService(Context.ALARM_SERVICE);
int interval = 1000 * 60 * initailDelay;
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), interval, pendingIntent);
Toast.makeText(getApplicationContext(), "Alarm Set", Toast.LENGTH_SHORT)
.show();
manager.cancel(pendingIntent);