Android system killed my service when I clear all recent app

前端 未结 5 2251
北海茫月
北海茫月 2020-12-13 10:39

I already using startforeground() at my Service, but Android keeps killing my Service when I clear all the recent apps.

Here\'

5条回答
  •  北海茫月
    2020-12-13 11:23

    you can use START_REDELIVER_INTENT instead of START_STICKY

    The simplest explanation of these could be,

    START_STICKY- tells the system to create a fresh copy of the service, when sufficient memory is available, after it recovers from low memory. Here you will lose the results that might have computed before.

    START_NOT_STICKY- tells the system not to bother to restart the service, even when it has sufficient memory.

    START_REDELIVER_INTENT- tells the system to restart the service after the crash and also redeliver the intents that were present at the time of crash.

    I hope this will help you. thanks

提交回复
热议问题