0

I see many reasons why an app should behave different if the device is connected to a power supply, via USB cable ore otherwise.

For example, with power on and effectively charging, it could be used as an image viewer, which would be prohibitive if running on battery.

So, how to let an app check if power supply is on, and, if the battery is charging or still running low (due to other power consuming processes or perhaps just because it's old and leaking).

Edit: in view of the comment that points to a method to get noticed of changes of power supply:

This is valuable, maybe for other applications, but I'm asking for actual power supply minus battery need for recharging.

Gyro Gearloose
  • 1,056
  • 1
  • 9
  • 26
  • There is an answer for this question [here is it](https://stackoverflow.com/a/6660230/8139353) – Mohammad Khair Dec 25 '20 at 14:12
  • @MohammadKhairPK Thank you, but this is only half of what I'm asking. No use if the device is connected but still not charging. I need to see if the power supply can sustain a power hungry app and still recharges, or at least does not deplete the batteries. – Gyro Gearloose Dec 25 '20 at 14:19
  • @MohammadKhairPK another back draw of your suggested solution is that the app must have been already running when the power cable was connected. Would not work if the power was connected beforehand, as the listener only reports changes. – Gyro Gearloose Dec 25 '20 at 14:31
  • Just check the battery status for a while. If it grows or stays the same its connected. – blackapps Dec 25 '20 at 17:19

0 Answers0