Search code examples
androidalarmmanagerandroid-wake-lock

Continuous warning message from WakefulBroadcastReceiver


I am using Alarm Manager to get triggers every 5 minutes. The alarm receiver extends WakefulBroadcastReceiver and on receiving an alarm trigger it starts an IntentService via startWakefulService(context,service). On receiving the intent in onHandleIntent(Intent intent) method inside the service, the app performs some desired stuff and at the end of this method it releases the wake lock by calling AlarmReceiver.completeWakefulIntent(intent).

My app is running fine but in the logcat I see the warning messages by the WakefulBroadcastReceiver.

Tag: WakefulBroadcastReceiver Warning message: No active wake lock id #1

These warning messages keeps on coming with every trigger and the #number increases every time. I am wondering if there is some issue with the alarm that is set up by the application because the messages are increasing gradually in number. Or is it just because the wale-lock is not created by the alarm manager and my app is trying to remove it via completeWakefulIntent.


Solution

  • Most likely startWakefulService and onHandleIntent were executed in different processes. In such case calling the static AlarmReceiver.completeWakefulIntent will behave as if it worked, but since the actual wake lock is not found in that process space you would get that warning message.