我想在应用程序崩溃时自动重启我的服务。我的想法是:
1: 当 apk 崩溃并自动重启服务时的 BroadcastReceiver
if("android.intent.action.SOMETHING".equals(intent.getAction()))
{
Intent serviceLauncher = new Intent(context, Service.class);
context.startService(serviceLauncher);
}
2: 有一个 uncaughtException(),但我不知道如何处理它
最佳答案
我认为你只需要在 Service 的 onStartCommand() 中返回 START_STICKY
关于android - 当 apk 崩溃时自动重启服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8605195/