AlarmManagerService not canceling alarm on time

27 views
Skip to first unread message

Ermir

unread,
Nov 6, 2012, 5:52:23 AM11/6/12
to android-...@googlegroups.com
Hi,

I have a problem with AlarmManagerService which is not canceling my alarm. 
I'm setting the alarm like this:

mAM = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
mWake = PendingIntent.getBroadcast(mContext, 0, new Intent("test.intent.wake"), 0);
mTimeout = PendingIntent.getBroadcast(mContext, 0, new Intent("test.intent.timeout"), 0);

...

mAM.set(AlarmManager.ELAPSED_REALTIME,  SystemClock.elapsedRealtime() + 30 * 1000, mWake); //trigger after 30 seconds

// after 30 seconds I cancel the alarm
mAM.cancel(mWake);


I had some logging in AlarmManagerService.java and most of the times the alarm is not on the mElapsedRealtimeAlarms list. What i have seen is that it is moved to a triggerList in function triggerAlarmsLocked(...) and removed from the mElapsedRealtimeAlarms. 

When calling the cancel method, it will look into mElapsedRealtimeAlarms list and not find it there. So cancel is useless. The alarm goes off and triggers the handler.

Why is the alarm removed from the list before it is triggered? This causes issues if i.e some activities are started vie the handler, which hold wakelocks. It will prevent the device from going into suspend.


Is there any solution to prevent this overlap of lists?

Thanks,
Ermir.


Reply all
Reply to author
Forward
0 new messages