Search code examples
androidbroadcastreceiverbattery

Android 8.0 and up: Monitor battery level changes while app is not running


As the title says, I am looking for a way to monitor the level of the device battery even while the app is not running. context.registerReceiver() worked out well, but sadly only with the app running.

Is there any way I did not think of?


Solution

  • This is became restricted starting from Android 8+. Have a look at the documentation ACTION_BATTERY_CHANGED

    You might try WorkManager to periodically check for battery status