rhnoble
rhnoble

Reputation: 569

Why might my android app occasionally drain battery extremely fast?

Several users of my app have reported their battery draining at around 1% a minute with my app running in the background. I have been unable to replicate this issue even when using the same account credentials on the same device model that the user had the error on. Reinstalling the app apparently does not solve the problem, and there does not seem to be any specific Android version or device associated with the issue. All the reports I've had are Samsung devices running 4.x, but this is also fairly representative of my user base overall. My background service listens for GCM messages and contact list changes as well as firing off an http request roughly every hour using a ScheduledExecutorService.

I should also note that I do not use any wake locks in the app.

I am wondering if anyone has any ideas as to what sorts of bugs might cause an issue like this, or even what tools or methods might be effective in narrowing down my problem scope.

Upvotes: 4

Views: 1720

Answers (3)

Duna
Duna

Reputation: 1612

Do not use Executors.newScheduledThreadPool(1) with scheduleWithFixedDelay with smaller amout of time like below 30 minutes. The CPU will never go idle and after intensive tests I found out the battery is drained 3% more every hour, if the scheduleWithFixedDelay is set to 5 minutes.

Upvotes: 0

Stephan Branczyk
Stephan Branczyk

Reputation: 9375

If I were you I'd

  1. Start testing with your wifi turned off.

  2. Test your application while simulating high latency (Charles has a free 30-days trial)

  3. And add some code for monitoring battery level and charging state.

I'm sorry I don't a better answer.

Upvotes: 0

Inquirer
Inquirer

Reputation: 7

About what percentage of users are reporting this problem? If you tried it on a Samsung device running 4.x and you didn't get an issue something besides your code must be the problem.

Upvotes: 0

Related Questions