How can I get battery level and state (plugged in, discharging, charging, etc)? I researched the developer docs and I found a BatteryManager class. But it doesn’t contain any methods, just constants. How do I even use it?
How can I get battery level and state (plugged in, discharging, charging, etc)? I
Share
Tutorial For Android has a code sample that explains how to get battery information.
To sum it up, a broadcast receiver for the
ACTION_BATTERY_CHANGEDintent is set up dynamically, because it can not be received through components declared in manifests, only by explicitly registering for it withContext.registerReceiver().