Accessing battery information

Version 1

    The battery information can be accessed by registering your application as a battery intent receiver as shown below:

     

    mIntent_Receiver = new Intent_Receiver();

    mIntentFilter = new IntentFilter();

    mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);

    registerReceiver(mIntent_Receiver,mIntentFilter);

     

    See http://developer.android.com/reference/android/os/BatteryManager.html for the values included as extras in the received intent.

     

    The attached sample demonstrates the use of Android BatteryManager APIs for accessing battery information such as temperature, % of remaining battery and voltage.