For those asking why it's so hard to get right, let me explain:
- Android provides a way to detect when the battery level changes but it only works while the app is running. The first version of the app used this approach, which works perfectly on my phone and many others. The problem comes if Android or an app killer decides to kill the app. When that happens, it can't update anymore.
- I went through several updates trying to make the above mechanism foolproof because when it works, it's perfect. The app does no unnecessary work and so it has very little impact on battery life.
- However, try as I might, it just doesn't seem to be possible to make the above approach 100% so I added a timer to the app that is supposed to double check that it's running and restart it if not. The timer runs every few minutes, but it's only supposed to run when the device is already awake from sleep, so it should still have little impact on battery.
- I think the latest issues are down to some phones not honouring the fact that the timer shouldn't run while the app is asleep so I'm about to release an update that stops the timer while the device's screen is off. Hopefully that will do the trick.
Why not just keep the original version that worked in place and just clearly state the widget has too be added to an ignore list for any app killers?
ReplyDeleteThere's still the issue that if the device runs out of memory the app gets killed and never restarted, making it unreliable. If done right, having a timer that only runs when the screen is on shouldn't a negligable amount of battery and give a responsive app. That's why that's what I'm trying to do.
ReplyDelete