I have a background service which runs in background to track screen on and off events. its started as below :
Intent intentService = new Intent(context, UnlockdService.class);
context.startService(intentService);
And it is returning Service.START_REDELIVER_INTENT
in the method onStartCommand. But still when android system kills app this thread dies as well.
How can I prevent it?
The solution was so simple: Returning START_STICKY
from onStartCommand()
did the job.