如何自动停止AlarmManager

时间:2015-07-26 01:45:52

标签: java android alarmmanager

我想从N o&time开始我的代码,然后运行到Y o&#clock时钟。我使用AlarmManager来实现它,如下所示:

AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

Intent intent = new Intent("net.arkellyga.checkservice");
intent.putExtra("text", etmessage.getText().toString());
pendingIntent = PendingIntent.getService(this,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);

// If service working now.
am.cancel(pendingIntent);
Log.i("AlarmManager", "Start working from " + d.getHours() + ":" + d.getMinutes());

am.set(AlarmManager.RTC, d.getTime(), pendingIntent);
am.setInexactRepeating(AlarmManager.RTC, d.getTime(), 60000, pendingIntent);

完美无缺!但是我怎么能停止这项服务呢?我需要AlarmManager自动停止在Y o'时钟。

最诚挚的问候,Arkellyga。

0 个答案:

没有答案