1

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?

SMR
  • 6,628
  • 2
  • 35
  • 56
Lai
  • 115
  • 1
  • 6
  • Related post - [Android : Difference between BATTERY_STATUS_DISCHARGING and BATTERY_STATUS_NOT_CHARGING](https://stackoverflow.com/q/10022960/465053) – RBT Sep 10 '18 at 00:02

2 Answers2

3

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".

TtT23
  • 6,876
  • 34
  • 103
  • 174
1

A chargeable device will not be charging all the time that it is plugged in.

It will charge until the battery is full, then it will wait until the battery level drops to a certain level before starting to charge again. If it would charge all the time the battery would get overcharged.

For example, a device might be set up so that it will start charging if the battery level drops below 80%. It will then charge it to 100% and then stop charging.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005