如何自动重启被杀死的服务? [英] How to restart a killed service automatically?
本文介绍了如何自动重启被杀死的服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
服务被杀后,如何自动重启?
When a service has been killed, how to restart it automatically?
有时甚至不调用onDestroy()
推荐答案
我继承了一个 IntentService,所以我必须要温柔.当我覆盖 onStartCommand() 但是
I inherited an IntentService, so I had to be gentle. It worked for me when I overrode onStartCommand() but
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
return START_STICKY;
}
也就是说,让父母做它应该做的事情并返回 START_STICKY.
That is, let the parent do what it should and return START_STICKY.
这篇关于如何自动重启被杀死的服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文