Я хочу запустить свой код с N часов, а затем работать до Y часов. Я использую AlarmManager, чтобы добиться этого следующим образом: [code]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); [/code] Все работает отлично! Но как я могу остановить службу? Мне нужно, чтобы AlarmManager автоматически останавливался в Y часах.