I trying to set a repeating task using the AlarmManager
the task is to send a broadcast to my BroadcastReciever that runs a service (if it isn't already).
this is the code which sets the repeating task:
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 10000 , 60 * 1000 , pendingIntent);
now the repeating task works fine, but if my application is still running, and I stop it, I don't get the broadcast anymore.
what am I doing wrong here?
the manifest: (only the relevant part)
<action android:name="android.intent.action.BOOT_COMPLETED" />
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent("com.xxxxx.tq.TQServiceManager"), PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000 , 30 * 1000 , pendingIntent);
How is your BroadcastReceiver registered? It must be in your AndroidManifest.xml file, and not manually registered. The fact that it works when your app is running and doesn't when your app is not running sounds like it isn't in the manifest.