Getting Battery Information on Android

Public on January 4, 2009
Getting the Battery Information in Android without Apps like AnyCut, Power Manager or System Monitor is one of the hardest task. You can try those if you have an Android phone, anyway here is how to get the Battery Information (some of the codes are undocumented).
public class Main extends Activity {
  private TextView contentTxt;
  private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){
    public void onReceive(Context arg0, Intent intent) {
      // TODO Auto-generated method stub
      int level = intent.getIntExtra("level", 0);
      contentTxt.setText(String.valueOf(level) + "%");

  public void onCreate(Bundle icicle) {
    contentTxt = (TextView) this.findViewById(;
    new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

Quick Explanation
Here we listen to a Intent (ACTION_BATTERY_CHANGED) and register a receiver when the intent is fired. In ActionScript, this is i believe is DispatchEvent, and we would call mBatInfoReceiver and get the current level of our battery life and put that int value to our textfield or TextView.

Source Code
My Battery Status 1 Source

Here is the source where i got the this stuff working

Update History
   Jan 17, 2012 - Visual Update

[Advertising]Faster Thinking - Speed up your brain

Faster Thinking Game

sentiment_satisfied Emoticon