Android service not restarting in lollipop

前端 未结 7 1300
借酒劲吻你
借酒劲吻你 2020-12-11 01:13

In my application, I use location based service in background. So I need to restart my service when it gets destroyed.

But I got this message in logcat

7条回答
  •  醉梦人生
    2020-12-11 02:07

    Your code in onTaskRemoved is preventing the system to run the killProcess commands. The delay on Kitkat is caused by using alarmService.set, which is inexact from API 19. Use setExact instead.

    If you have a service that you want to keep alive, it is recommended that you attach a notification to it and make it foreground. That way the likeliness of it being killed would be lowered.

提交回复
热议问题