I'm working on Android 12 and I try to (force) kill my foreground service.
I can kill it from adb by the command: adb shell force-stop "my service"
But when I do it programmatically (as was suggested by How to kill an application with all its activities?) the OS restarts the service after it was killed.
That's my code which kill the service but then is initialized by the Android OS:
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
Any idea?
Thanks