Search code examples
androidbroadcastreceiverbatterymanager

What is the difference between BATTERY_STATUS_CHARGING and BATTERY_PLUGGED_AC?


I am learning about broadcast receiver, and following the official docs

What is the difference between
BatteryManager.BATTERY_STATUS_CHARGING
and BatteryManager.BATTERY_PLUGGED_AC

I use telnet localhost 5554 and type power ac off then power ac on. I expected BATTERY_STATUS_CHARGING to be fired automatically, but it didn't. Why?

Why AC is plugged in does not imply charging?


Solution

  • BATTERY_PLUGGED_AC means that the device is plugged in to an AC adapter. The "counterpart" of this would be BATTERY_PLUGGED_USB. Note that this has nothing to do with charging status.

    While for BATTERY_STATUS, there are basically 4 types: BATTERY_STATUS_CHARGING, BATTERY_STATUS_NOT_CHARGING, BATTERY_STATUS_DISCHARGING and BATTERY_STATUS_FULL. You will receive different notifications based on their battery status.

    Just because the device is plugged in, doesn't always mean it is charging which is why BATTERY_STATUS_CHARGING is not fired when you do "power ac off" then "power ac on".