I am having a problem with Alarmmanager features for Android.
The problem is that alarms that have more than an hour or so to wait do not go away.
My application initially creates this signal: -
PendingIntent sender = PendingIntent.getBroadcast(this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, mCal.getTimeInMillis(), sender);
When the alarm goes off, it calls my RecieverHandler class, in particular this function: -
public void onReceive(Context context, Intent intent) { try { Bundle bundle = intent.getExtras(); Intent newIntent = new Intent(context, MessageDispatcher.class); newIntent.putExtras(bundle);
Then a service called MessageDispatcher is launched, and this function is called: -
public int onStartCommand(Intent intent, int flags, int startId)
This function receives the next alarm time from my database, I am sure it works correctly, and then sets a new alarm based on the date from the database as follows: -
PendingIntent sender = PendingIntent.getBroadcast(this, 192837, newIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, mCal.getSendAt().getTimeInMillis(), sender);
This creates an alarm for the next message.
I tested it in a short amount of time and it seems to have worked and tested it for a lot of time, changing the date and time on the phone. It seems to have worked successfully.
Then, when this signal goes off, it receives the next alarm and turns it off. I am almost 100% sure that these parts work fine.
So, I am stuck with only some theories why it does not work.
I thought that this could be due to disconnecting the phone from the debugger, but in this case the alarm works for a short period of time.
So, my main theory is that the creator of the alarm clock that I create, is deleted after a certain amount of time? If true, this is a big problem since I need it to work no matter how much time has passed.
Any help in ensuring my anxiety remains very appreciated, thanks.