views:

956

answers:

1

Is there a way to get battery information from the Android SDK? Such as battery life remaining and so on? I cannot find it through the docs.

+3  A: 

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. The docs say that the broadcast is sticky, so you'll be able to grab it even after the moment the battery state change occurs.

Jarett
This is exactly what I was looking for. Thanks a lot.
Jeremy Edwards
No problem. I know how hard the Android SDK docs can be to navigate sometimes.
Jarett
Can you post some sample code for this. I'm not sure how to receive a broadcast intent.
Jeremy Edwards