开发者

Bind unbound Services in Android

I'm developing a Android Service. I would like the service to run even when the application not is active. So I start it without binding it:

startService(new Intent(Service.class.getName()));

Now it will run continuously until I choose to stop it, right?

If I, from anot开发者_高级运维her activity, bind the service will it stop when I unbind it?


Not necessarily. However, you have to remember that if there is memory pressure, it may be killed depending on the priorities (and if it is unbound, any visible app will probably have higher priority). The lifecycle is described here: http://developer.android.com/reference/android/app/Service.html#ProcessLifecycle


When the last client unbinds from the service, the system destroys the service (unless the service was also started by startService()).

It mean that your service will not stop even you unbind service from all activity in case of you had started service as startService()

For more details about bound service follow bellow link

Bound services

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜