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

耗尽温柔 提交于 2019-12-02 18:49:31

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.

Pushing up the comment of KR_Android : according to this blog and this other question : a service Intent is declared 'bad' after crashing at least twice.

Please try to

  • Encapsulate all methods in try { method(..); } catch(..) { log(..) } security belts
  • Deinstall and reinstall the app

Let us know and we shall update our answers after digging further

It annoyed me that the system wouldn't restart my service until I rebooted the box. Then I found this trick to clear the crash counts much more quickly:

adb shell killall system_server
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!