搜索
您的当前位置:首页正文

service小问题

来源:哗拓教育

1.bundService 相当于将service中的一个int型size大小++,startService即将service中的一个boolean变量置为true

* bundService         intSize++
* startService          isStart=true

相反的

* unbundService   intSize--
* stopService/stopself isStart=false

只有intSize==0 && isStart ==false 同时满足时service才被干掉,否则不会消亡(这里注意多次unbundService ,intSize <0时会崩溃)

  • 2.service 跟activity 通信 ,使用binder。
    1. 当使用远程service时 :android:process=":remote"
      需要使用AIDL
      参考:
Top