The BatteryManager interface provides ways to get information about the system’s battery charge level by interacting with Battery Status API
We can use the Battery Manager to detect
- charging state
- Battery percentage
- Time needed to charge 100%
- The remaining time until the battery is completely discharged.
1 | let { |
If we wish to get the status on change, we can add listeners for the respective properties. There is a function to do the same. \O/
- onchargingchange
- onchargingtimechange
- ondischargingtimechange
- onlevelchange
Note: This feature has been deprecated from the web standards. But it is always fun know something new, is it not? ^_^