如何自动重新启动该服务在android系统? [英] How to restart the Service Automatically in android?
本文介绍了如何自动重新启动该服务在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开始在Activity.Now服务,如果我强行关闭活动,然后自动的服务也迫使stopped.Is有什么办法可以自动重新启动它。?
先谢谢了。
I have started a service in Activity.Now, if i force close the activity then automatically the service is also force stopped.Is there any way to restart it automatically.? Thanks in Advance.
推荐答案
您必须实施 onStartCommand()
通过返回方法 START_STICKY
或 START_REDILIVER_INTENT
,但它是你的责任,通过调用停止服务 stopService()
或 stopSelf()
方法。
You must implement the onStartCommand()
method by returning the START_STICKY
or START_REDILIVER_INTENT
, but it's your responsibility to stop the service by calling stopService()
or stopSelf()
method.
这篇关于如何自动重新启动该服务在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文