I have a task that needs to run frequently on an Android device. I run the following code on boot:
am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
pollIntent = new Intent(context,PollTask.class);
pollPendingIntent = PendingIntent.getBroadcast(context, 0, pollIntent, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), 1000*15, pollPendingIntent);
Please don't nag me about battery use, this is for a custom embedded application, so it's not an issue.
What is an issue is that this task stops running frequently after a certain amount of time. I started viewing the logcat and noticed that every 15 seconds, after it stopped working, I would get an error saying that the intent could not be launched and that the "process is bad." At this point, I was using a separate process with the code
android:process=":remote"
in the Android Manifest for the PollTask broadcast receiver.
I removed this bit of the code, so that I'm now just running the broadcast receiver on the default thread. It seems to be working, but I'd be more satisfied if I knew what the exact issue was. Unfortunately, the error message that I mentioned before was not at all verbose. I'm still testing this on a couple of devices right now, to see how long it'll run continuously.
What do I need to know about this error? Is there any downside to using the same process?