我想从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。