服务运行的次数

SKB*_*SKB 1 service android android-activity

我的应用程序中有三个活动,所有这些活动都需要访问服务.因此,如果我启动服务三次,它将启动三次或仅启动一次.并且如果在重新启动服务时将删除先前的数据.

感谢名单

Vin*_*kla 5

如果你是startService第一次启动它的onCreate方法将调用它的方法,你启动服务的次数并不重要,但是它的方法onStartCommand(Intent, int, int)将根据你的startService调用进行调用.stopService无论您拨打多少次电话,服务都会停止startService.

停止服务时不要忘记释放资源,线程.

你可以参考这个文档:

http://developer.android.com/reference/android/app/Service.html