How to read battery info on Android with Adobe AIR

With Adobe AIR native extensions, it is extremely easy to read the battery data of your android device from within your AIR application. Here is how to get going…

 

1. Download the free version of our native extension – DroidBattery – from:

http://flashvisions.com/goodies/air-android-extensions/droidbattery/

 

2.  Create  a instance of DroidBattery :

var droidBattery:DroidBattery = DroidBattery.getInstance();

 

3. Request batterydata through public function getBatteryData()

var batteryData:BatteryData = droidBattery.getBatteryData();
trace(batteryData.rawLevel);
trace(batteryData.scale);
trace(batteryData.temperature);
trace(batteryData.voltage);

 

4. Destroy the instance before closing your application

droidBattery.destroy();

 

Download flashdevelop source

Download APK

 

3 Comments - Leave a comment
  1. Hi

    I have used your Native Extension in my app

    batteryData.rawLevel
    batteryData.scale
    batteryData.temperature unit is Celsius ?
    batteryData.voltage it gives me 4138, is 4.138 volt?

    Thanks

  2. and what is rawLevel and access ?

    Thanks for your great NAE

  3. Sudar says:

    Hi,
    Can i get the dynamic battery value whenever it changes on device for Android AIR application?

    Regards,
    Sudar

Leave a Reply

Your email address will not be published. Required fields are marked *

*