llller
2011-10-26 22:28
浏览 200

关于aidl的问题???????

有两个应用A和B,通过aidl来来共享服务,现在有个问题:
当我想把服务Destroy的时候,为什么要A和B都unbind后,才会Destroy;为什么不是谁create的,就由谁Destroy??????

你们能看懂我说的吗?????

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 李文栋 2011-11-01 18:03
    已采纳

    官方文档上写的很清楚,即便你调用了stopService,但系统只会在当前服务的
    请求者全部unbind后,才会真正停止这个Service。

    public abstract boolean stopService (Intent service)

    Since: API Level 1
    Request that a given application service be stopped. If the service is not running, nothing happens. Otherwise it is stopped. Note that calls to startService() are not counted -- this stops the service no matter how many times it was started.
    Note that if a stopped service still has ServiceConnection objects bound to it with the BIND_AUTO_CREATE set, [color=red]it will not be destroyed until all of these bindings are removed.[/color] See the Service documentation for more details on a service's lifecycle.

    已采纳该答案
    打赏 评论
  • doudou343 2011-11-01 23:02

    你多次绑定一个服务的时候,service的onCreate()方法只调用一次。

    打赏 评论

相关推荐 更多相似问题