Recently I have developed an android app . The app is ok . But the user is complaining that app causing battery drain . Even some battery optimizer app (Like Battery Doctor) suggesting my app to force stop as it is causing battery draining too fast . There are a lot of service (like sync service , socket service) and broadcast receiver is used in this app and alarm manager is used in the app. How can I detect actually which is responsible for battery draining ?
Asked
Active
Viewed 3,042 times
1
-
2Start by assessing if wakelocks are used in the code, maybe there's a chance that it was not released? Also, this sort of presumptious claim by a user is hunting for needle in haystack, chances are google play services is notorious for battery drains, also, what sort of apps is that user have running, not to mention, the android version, without those critical information, chasing something down that *may* not be in your code after all. – t0mm13b May 29 '16 at 11:40
1 Answers
3
I addressed the major contributors to battery drain in another of my posts.
If I understand correctly, you want to identify which section of code (including libraries) of your app is the culprit.
Here's my suggestion:
- Confirm that there is a problem: Get as identical a phone configuration as possible, say by having the user send a dump of all processes running on their phone, and confirm there is a problem.
- Confirm that it's your app: run tests with your app running and without. Make sure you take several measurements.
- (A) If you have a profiler, use it to profile your application and identify potential issues. (B) If you don't have a profiler, create some dummy input, and start exercising your app while cutting out different functionality. Measure the battery drain.
NOTE: If the drain is small, detection becomes an issue. It's the old signal to noise ratio thing. The smaller the drain, the more measurements you have to take to determine what it is. Of course, the smaller the drain, the less of an issue it is.

Community
- 1
- 1

Taylor Kidd
- 1,463
- 1
- 9
- 11