1. Download our Official Android App: Forums for Android!

Apps BatteryManager

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

  1. patherrod

    patherrod Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Jun 18, 2012

    Jun 18, 2012
    1
    0
    5
    Hi,

    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?
     

    Advertisement

Share This Page

Loading...