1. Check out our companion app, Forums for Android! Download from Google Play


Discussion in 'Application Development' started by patherrod, Jun 18, 2012.

  1. patherrod

    patherrod New Member
    Thread Starter

    Jun 18, 2012

    I'm writing an application for the original galaxy tab that is running 2.3.6. One of the features of the application is to return battery data from the BatteryManager. I used the development tutorials, resources and references from the android development website. I'm have problems when determining when the tab is charging. I use this code:

    int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;

    The problem is that the status variable always has a value of 4, which is public static final int BATTERY_STATUS_NOT_CHARGING
    Since: API Level 1
    Constant Value: 4 (0x00000004)

    so no matter how the tab is plugged in, by ac or usb, or not plugged in, status = 4. Is this a firmware thing? Or a tab thing? Any ideas?


Share This Page