Version | Adjustments |
---|---|
1.0 (2020-01-25) | Initial version |
1.1 (2020-03-07) | URL to this page corrected |
1.2 (2024-09-04) | Adapted to Android 14 |
For a future project I want to control a smartphone remotely, i.e. I don't have direct access to the device. For this project, I would like to find out about the battery charge status. The smartphone should be checked by an app created with the App Inventor. Unfortunately there are no corresponding functions there. But you can make it available through a self-made extension.
The ZIP archive UrsAI2Battery for download. The archive contains the source code, the compiled binary for uploading to App Inventor and a sample application.
The extension provides a number of properties that provide information about the battery status. Not all values are available on all smartphone types. In this case, clearly recognizable error values are returned.
Block | Typ | Funktion | Fehlerwert |
---|---|---|---|
Integer | Returns the remaining capacity of the battery in percent. | -1 | |
Integer | Returns the remaining charge of the battery in mAh. | -1 | |
Integer | Returns the remaining energy of the battery in mWh. Can be estimated from voltage and residual charge if necessary. |
-1 | |
Integer | Returns the current battery voltage in mV. | -1 | |
Integer | Returns the current power consumption in mA. A positive value is the discharge current, a negative value is the charge current. |
-99999 | |
Integer | Returns the average current consumption in mA. A positive value is the discharge current, a negative value is the charge current. The time period over which the average is calculated may depend on the hardware and its configuration. |
-99999 | |
Boolean | Indicates whether the battery is currently being charged. | false |
A small sample app shows the use of the extension (see download).
You can see that some features are not supported on the test device.