I'm running my app (an alarm clock) on a pixel with android 8.0 and my app's battery usage in mAh keeps rising with no active or background use changes. It shows no running services and doesn't do any background work. After noticing the constant rise, I closed and force stopped the app, but the battery usage kept rising at the same rate even afterwards. This is not the first time I've seen this behaviour and it only seems to affect my app (no other apps on my phone do this). Is there some way for an app to leak resources even after being closed and force stopped?
Asked
Active
Viewed 79 times
1

spaceman
- 118
- 1
- 2
- 10
-
1Do you use anything to start the app in the Background? E.g. you wanted the clock to automatically start when booting the phone? Seems like a normal thing to do with a clock and this might cause your app to restart after you forced it to close. Anyway it's hard for us to tell you, what your app is doing without any code. – Leo Nawroth Nov 01 '17 at 17:01
-
I use a BroadcastReceiver to listen for reboots and restart the alarm if the user reboots while the alarm is still active. I understand that it's hard to diagnose without code and I'd love to show some, I just don't know where to begin cause I don't know what areas are relevant and could potentially be problematic. Is there a way that the app could be running in the background without showing up in the running services section and while being force stopped? – spaceman Nov 01 '17 at 17:08
-
1How about you disable that BroadcastReceiver and see if it still happens? – Leo Nawroth Nov 02 '17 at 11:14
-
I tried it for the last two nights and it didn't change anything so far. I read in this post https://stackoverflow.com/questions/4549635/do-android-broadcast-receivers-consume-battery-life that a boot receiver doesn't use much battery, but if I understand correctly it will only fire if the device reboots right? It isn't in a constant state of "listening" in the background? – spaceman Nov 04 '17 at 15:59
-
1I don't think the BroadcastReceiver itself is your problem. My wild guess (remember: I don't have your code) would be, that your app restarts itself and uses the hardware excessively. So the BroadcastReceiver just might be the tool that restarts your app. But your code is probably doing all the battery draining work. – Leo Nawroth Nov 08 '17 at 10:28
-
But wouldn't that make the apps active use go up in the battery stats? – spaceman Nov 08 '17 at 16:21