Sticky foreground service fails to restart with a “process is bad” error

后端 未结 3 1771
故里飘歌
故里飘歌 2021-02-01 14:53

I have a started foreground service. I\'ve taken care to return START_STICKY from onStartCommand. I\'ve observed that foreground services don\'t run indefinitely bu

3条回答
  •  无人及你
    2021-02-01 15:27

    For your vanilla version of your service, consider followings:

    1- uninstall your app 2- reboot your device 3- reinstall your vanilla service version to just logging.

    It should work.

    For your foreground service consider using stopSelf or stopService methods and not stopForegroundService method. stopForegroundService just stop the service from being a foreground. It does not stop it from being a background service. It restarts over and over and if your service going to crash or not doing his job within 5 seconds, so OS kill your service over and over and eventually your service is going to blacklist of OS.

提交回复
热议问题