Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the number of battery charges?

as mentioned above, I want to get the total number of battery chrarges. The batery Intent I'm already using only shows me Level, Voltage, Temperature ... but not the total loading cycles.

like image 480
Tobias Avatar asked Jan 10 '11 17:01

Tobias


1 Answers

You can register an Intent receiver to receive the broadcast for ACTION_BATTERY_CHANGED: http://developer.android.com/reference/android/content/Intent.html#ACTION_BATTERY_CHANGED.

Broadcast Action: This is a sticky broadcast containing the charging state, level, and other information about the battery. See BatteryManager for documentation on the contents of the Intent.

You can not receive this through components declared in manifests, only by explicitly registering for it with Context.registerReceiver(). See ACTION_BATTERY_LOW, ACTION_BATTERY_OKAY, ACTION_POWER_CONNECTED, and ACTION_POWER_DISCONNECTED for distinct battery-related broadcasts that are sent and can be received through manifest receivers.

This is a protected intent that can only be sent by the system. Constant Value: "android.intent.action.BATTERY_CHANGED"

like image 102
fulvio Avatar answered Oct 04 '22 22:10

fulvio