My android signals are canceled, not by me
In my application, an alarm timer checks for updates on the server every 2 minutes. I am creating a repeating timer using this:
alarmIntent = new Intent(context, OnWakeUpReceiver.class);
PendingIntent pIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 120000, pIntent);
For the vast majority of people, this works great. But a small number of people report that the app suddenly stops updating itself. I put in a simple check that sees if a timer exists:
PendingIntent pIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_NO_CREATE);
and of course, when the app is no longer updated, this returns null, indicating that the timer doesn't exist yet.
My app controlled the alarm timer (turned off when there was no network connection, then turned back on when there was, and other scenarios). I thought that maybe I somehow disabled it and didn't put it back. So I created a version where I deleted every call to cancel the alarm timer. Therefore, my application no longer has the means to cancel this timer. But after just a few days, the alarm timer is no longer present and the app is not updated.
I have not been able to get this to happen on my own systems, or someone will find a reliable way to replicate this on their own. I wondered if the Android system could cancel it (although it will stop my app from ever working again), but on one of the problematic systems, he said that he had almost nothing working on the phone.
I didn't know if task killers could kill alarm timers, but I realized that after I think SDK 8, task killers could no longer do this and I had problems with post-version 8. And also in systems that don't run task killers and are not rooted.
I even created a "watchdog" alarm timer in which the receiver was triggered to check if the update to the main application timer stopped. What I found was that the THAT timer was canceled as well (it gave no further "last run" updates and never noticed the main app stopped).
This problem is an application killer for me. Can anyone suggest any way to even try and debug when and what happens? Is there any log entry ever made by the system when the timer is canceled, be it the system or something else? I hate that it just evaporates without a trace.
source to share
I can't say this is a complete answer, but these 2 changes together seem to have stopped the MUCH of canceled alarms:
1) I accepted the pending intent and canceled that, as opposed to calling cancel () in the alarm manager where I had to cancel the alarm for whatever reason. Over time, I don't know if this managed to confuse the alarm manager or something, but it was probably bad. Now I am canceling the alert dispatcher as well as the pending intents.
2) One of my users mentioned how when they click Clear RAM it disables my service. Apparently some phones come with a task manager that gives them a nice shiny button that allows them to clear their memory / RAM. The button even makes it clear that clicking on it will cause some applications to stop working ... and users will slow down anyway. I don't know how exactly, but it seems to be killing my worries a LONG time. So I gave a big notice to people to stop doing this and things have really calmed down since then. The sucking side is that I will never know the next time I get a disabled alarm, if the user presses the magic death button or something really went wrong.
But in any case, everything is better.
source to share