Wake Lock Not Working Properly
Solution 1:
I don't understand your problem, exactly. I can say, though, that Android only guarantees that it is holding a wakelock while it delivers the Broadcast. Your code leave considerable time between the reception of the Broadcast, by the Receiver, and the time you seize the wakelock. There is nothing to prevent the device from going back to sleep, in that interval.
Solution 2:
While AlarmManagerHelper.onReceive
runs the system holds a lock (because of the Alarm manager) that will not fail. But between the context.startActivity(i);
and the starting of the activity the system falls asleep again. You need to either use a WakefulBroadcastReceiver (see BroadcastReceiver Vs WakefulBroadcastReceiver) or (that's what I use) a WakefulIntentService.
In any case you need to start a service and start your activity from there. For the WakefulIntentService pattern see my answer PowerManager.PARTIAL_WAKE_LOCK android and links there.
Post a Comment for "Wake Lock Not Working Properly"