1

I am adding intent filter for battery power connected and disconnected events inside my app's AndroidManifest.xml file and registering PowerConnection receiver as given in this link: https://developer.android.com/training/monitoring-device-state/battery-monitoring.html. But when I connect and disconnect my device with power source the receiver not invoked. When I am registering the same receiver programatically within my activity class, it is working fine. I want to invoke this receiver with power events when my app is not running by registering it manually inside AndroidManifest.xml. Please help me on this.

Abhishek Kotiyal
  • 283
  • 1
  • 5
  • 17

1 Answers1

6

If you are using API 26 and above, this method does not work. Read this: https://developer.android.com/about/versions/oreo/background I am also try to sovle similar problem. Now created a foreground service that starts at boot and monitors the status of the charger.

ProY
  • 59
  • 1
  • 5