0

I work for a music app company and I want to measure the amount of battery used by the App in real time, both for iOS and Android. Is there tool which can measure it or a command line utility/debug scripts which can be used as logs to optimize the app.

Any input would help a lot.

Thanks, Shyam

Shyam
  • 23
  • 1
  • 5

2 Answers2

0

To my knowledge there is no pre-build tool to do this. You can however implement a BroadcastReceiver using the BatteryManager class and log the changes in battery yourself.

Since your goal is to optimize battery usage, I strongly suggest you read these two articles.

http://developer.android.com/training/monitoring-device-state/index.html

http://developer.android.com/training/monitoring-device-state/battery-monitoring.html

Thomas
  • 203
  • 2
  • 4
  • Just don't monitor the battery level too frequently. Doing so is a common mistake that can by itself drain your battery even more. Figure out the minimum resolution (i.e. largest interval) you need, e.g. every 15 sec, and use that. – Taylor Kidd Mar 15 '15 at 15:08
  • Personally don't develop for iOS. You should be able to do something similar in iOS though using a similar API. The settings menu under Battery also will tell you how much percentage of the battery your app is using. You can see if this will work for you as well. – Thomas Mar 17 '15 at 20:33
0

OK, here's a shot in the dark. In many Linux systems, there's a status and monitoring virtual file system under either /proc or /sys. It contains information that is either on demand or periodically refreshed. For example, I obtain (almost) real-time data on voltage, current and power for a the Intel Xeon Phi coprocessor hanging off the PCIe bus. Logging into the coprocessor, which is running Linux, I read as a text file /sys/class/micras/power. You may find your iOS or Android system has a similar status/monitoring file called something like "battery".

Taylor Kidd
  • 1,463
  • 1
  • 9
  • 11