I have a boot_compiled receiver that receives notification on boot.
<receiver android:name=".BootCompletedReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>
But it seems to be called several times. I start the timer, and then the service, which leads to several timers, and then the service gets reset and starts again.
Create a timer. This is not a repeating timer, is it ?:
private void setAlarm(Context context, long interval) { try { AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(RespondAlarmReceiver.ACTION_RESPOND_SMS); intent.putExtra("isChecking", true); PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); int alarmType = AlarmManager.ELAPSED_REALTIME_WAKEUP; long triggerAtTime = SystemClock.elapsedRealtime() + interval;
As a side note, if anyone knows how to connect an Eclipse debugger to a broadcast receiver for downloading or to a running service, that would be fantastic.
amit
source share