do you have link/tutorial for compare the battery level before and after an activity/computation process?
Asked
Active
Viewed 159 times
-1
-
3There are many links on battery usage in the **Related** column, over there --> – Sam May 06 '12 at 15:56
1 Answers
1
For most devices, the granularity of reported battery changes is 1% of capacity. If your "activity/computation process" consumes more than 1% power, it had better be running for quite some time.
That being said, call registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED))
. Since ACTION_BATTERY_CHANGED
is a sticky broadcast, the registerReceiver()
call will return the last broadcast Intent
. Then, retrieve the BatteryManager.EXTRA_LEVEL
and BatteryManager.EXTRA_SCALE
values to determine the battery level. Just bear in mind that:
While
EXTRA_SCALE
is frequently 100, it is not always 100While
EXTRA_LEVEL
frequently changes in increments of 1 (e.g., 100, 99, 98), it does not always change in increments of 1

CommonsWare
- 986,068
- 189
- 2,389
- 2,491