- Category: Articles
After a number of spurious issues with the Electric Dawn alarm were reported, I finally narrowed it down to the wake lock and the broadcast receiver.
To (over)simplify, when the AlarmManager fires your BroadcastReceiver's onReceive function it only guarantees to wake the device for the duration of that function. When then firing an intent to launch the Activity there's no knowing how long you have before the device may go back to sleep. Initially the WakeLock was acquired in the Activity's onCreate function just after the layout was set. For the vast majority of users and devices this worked correctly. However, more recent installs on the later Android 2.3.3+ have shown interesting cases where the Activity is launched, complete with layout (buttons), but nothing happens thereafter.
The Electric Dawn release 1.2.19 now addresses this by acquiring a static WakeLock in the BroadcastReceiver's onReceive function before launching the Activity. This should certainly improve the reliability of the application for all users.
Further discussions on WakeLocks and BroadcastReceivers can be found on Android Developers - Google Groups