• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps NODE: AlarmManager, PowerManager.WakeLock and asynchronous call?


Feb 24, 2016
I have a class called AlarmHandlerAndReceiver (extends BroadcastReceiver) that has a method to set the AlarmManager, another one to cancel AlarmManager and nother one to reschedule AlarmManager and sure the onReceive

When onReceive takes place I acquire a PowerManager.WakeLock, send an intent to the app service then i ReScheduleAlarm and then release PowerManager.WakeLock

This means that i want to execute a take (intent) in the service in a periodic manner, say from minute to minute.

So my question is:

When the onreceive takes place i use a PowerManager.WakeLock in order to avoid device fall asleep to be possible to reschedule the alarm again.
However, the task call (on the service) is asynchronous (Intent) and in the meanwhile the PowerManager.WakeLock is released in the AlarmHandlerAndReceiver class.

What hapens if the service task is still running and the device fall asleep?
Is it needed to protect this? Should i make a synchronous task call (via application class?)

Thanks a lot



We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.