0

I need to perform background operations when my app is completely killed.I want to send data to the server in every 10 second when my app is killed. how to perform this task.

Sahil
  • 111
  • 1
  • 1
  • 5
  • You cannot do anything in the background every 10 seconds. That behavior is horrible for battery life, so Google has been steadily blocking that sort of behavior, starting back in Android 5.0. – CommonsWare Oct 30 '20 at 16:51

1 Answers1

0

When Android kills your app process, it can do nothing at all. Android prevents apps from doing background work in order to save battery and bandwidth for the end user. Only system processes can stay running indefinitely. I suggest reading the documentation to understand how it works.

If you want to do background work in a battery-efficient way, you should use WorkManager to schedule that.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441