Android: Scheduling Restart Of Crashed Service With Huge Delay?
I have a service running which the OS is killing - the problem is that when it kills it and schedules the restart, it's being scheduled to restart over an hour later. This service
Solution 1:
I was totally in the same situation. Restart time was really huge around 3M-9M ms.
I did a lot of research about this issue and many times I found that startForeground can solve everything. But I wasn’t satisfied with this solution.
In my situation I used HandlerThread to process background tasks and the solution was to change this thread priority THREAD_PRIORITY_BACKGROUND to the default. The annoying thing was that I found THREAD_PRIORITY_BACKGROUND in an official service example.
The onStartCommand still not being called but after I moved everything to onCreate (onStartCommand just returns with START_STICKY), now everything is working fine.
Post a Comment for "Android: Scheduling Restart Of Crashed Service With Huge Delay?"