I would like to create an android app that checks the external battery state (charge via micro USB).
I have checked the BatteryManager, UsbAccessory and UsbManager classes it seems non functional.
So any hints?
Thank you.
Check battery life & useOpen your phone's Settings app. Under "Battery," see how much charge you have left, and about how long it will last. For details, tap Battery. For a graph and list of battery use, tap Battery Usage.
Go to the activity_main. xml file, which represents the UI of the project. Add a Button, so whenever the user will click on the Button a Toast message with battery percentage will be popped up on the screen.
Select Search on the taskbar, type Command prompt, press and hold (or right-click) Command prompt, and then select Run as administrator > Yes. At the command prompt, type powercfg /batteryreport, then press Enter. The battery report will be an HTML file that's stored in a folder on your PC.
Android has a few hidden codes that you can punch into your Phone app to access testing menus. One of these displays a variety of info about your device, including its battery health. To see it, open your dialer and type *#*#4636#*#*.
As far as the phone is concerned, an external battery is just a power source like a normal charger. There is no communication; in fact these external batteries short-circuit the two data pins of the USB port to signal their prescence. Since they also contain circuitry to produce constant 5v output voltage the phone has not even a theoretical chance of knowing the battery state. I'm sorry but you are fighting a losing battle here, you will only be able to tell whether the phone is still receiving sufficient power from the external battery or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With