Android: Scheduling restart of crashed service with HUGE delay?

后端 未结 1 1256
野性不改
野性不改 2020-12-11 07:04

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

相关标签:
1条回答
  • 2020-12-11 07:57

    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.

    0 讨论(0)
提交回复
热议问题