0

I want to run a service which will watch all running service and running application. So for this i want to run my service permanently in background which can not be stopped by any other service.

Badoniya
  • 147
  • 1
  • 1
  • 9

1 Answers1

2

From your description it seems you need to Foreground your Service:

Make this service run in the foreground, supplying the ongoing notification to be shown to the user while in this state. By default services are background, meaning that if the system needs to kill them to reclaim more memory (such as to display a large page in a web browser), they can be killed without too much harm. You can set this flag if killing your service would be disruptive to the user, such as if your service is performing background music playback, so the user would notice if their music stopped playing.

You can do that by calling startForeground.

XorOrNor
  • 8,868
  • 12
  • 48
  • 81