Service官方教程(10)Bound Service的生命周期函数
Managing the Lifecycle of a Bound Service
When a service is unbound from all clients, the Android system destroys it (unless it was also started with onStartCommand()
). As such, you don't have to manage the lifecycle of your service if it's purely a bound service—the Android system manages it for you based on whether it is bound to any clients.
However, if you choose to implement the onStartCommand()
callback method, then you must explicitly stop the service, because the service is now considered to be started. In this case, the service runs until the service stops itself with stopSelf()
or another component calls stopService()
, regardless of whether it is bound to any clients.
Additionally, if your service is started and accepts binding, then when the system calls your onUnbind()
method, you can optionally return true
if you would like to receive a call to onRebind()
the next time a client binds to the service. onRebind()
returns void, but the client still receives the IBinder
in its onServiceConnected()
callback. Below, figure 1 illustrates the logic for this kind of lifecycle.
Figure 1. The lifecycle for a service that is started and also allows binding.
For more information about the lifecycle of a started service, see the Services document.
Service官方教程(10)Bound Service的生命周期函数的更多相关文章
- Service官方教程(11)Bound Service示例之2-AIDL 定义跨进程接口并通信
Android Interface Definition Language (AIDL) 1.In this document Defining an AIDL Interface Create th ...
- Service官方教程(7)Bound Service示例之1-同进程下直接继承Service
Extending the Binder class If your service is used only by the local application and does not need t ...
- Service官方教程(8)Bound Service示例之2-跨进程使用Messenger
Compared to AIDL When you need to perform IPC, using a Messenger for your interface is simpler than ...
- Service官方教程(6)Bound Services主要用来实现通信服务,以及3种实现通信的方案简介。
1.Bound Services A bound service is the server in a client-server interface. A bound service allows ...
- Service官方教程(3)Bound Services
Bound Services 1.In this document The Basics Creating a Bound Service Extending the Binder class Usi ...
- node-webkit教程(10)Platform Service之File dialogs
node-webkit教程(10)Platform Service之File dialogs 文/玄魂 目录 node-webkit教程(10)Platform Service之File dialog ...
- Service官方教程(4)两种Service的生命周期函数
Managing the Lifecycle of a Service The lifecycle of a service is much simpler than that of an activ ...
- Service官方教程(1)Started与Bound的区别、要实现的函数、声明service
Services 简介和分类 A Service is an application component that can perform long-running operations in the ...
- Service官方教程(9)绑定服务时的注意事项
Binding to a Service Application components (clients) can bind to a service by calling bindService() ...
随机推荐
- uva558 Wormholes SPFA 求是否存在负环
J - Wormholes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Stat ...
- 蚂蜂窝VS穷游最世界-自由行类App分析
很多其它内容请关注博客: http://www.china10s.com/blog/? p=150 一.产品概述 体验环境: 机型:iPhone 6 型号:64G版 系统:iOS9.2 蚂蜂窝APP版 ...
- 【C】字符串,字符和字节(C与指针第9章)
C语言没有一种显式的数据类型是字符串的. C语言存储字符串:字符串常量(不能改动).字符数组或动态分配的内存(能够改动) *************************************** ...
- [IT学习]阿铭Linux 微信公众号 每日一题 解析
1.shell习题171020公布的昨日答案 习题171019 - 打印正方形 #!/bin/bash read -p "please input a number:" sum a ...
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) D.Dinner Bet 概率DP+排列组合
题目链接:点这里 题意: 1~N标号的球 现在A有C个,B有C个 每次可以随机得到D个不同的球(1~N);问你A或B中的C个球都出现一次的 期望次数 题解: dp[i][j][k]表示 随机出现了i个 ...
- hadoop打jar包
编译: javac -classpath hadoop的路径下面/hadoop-0.20.0-core.jar -d .class文件存放的路径 XXXX.j ...
- C项目实践之通讯录管理案例
1.功能需求分析 通讯录管理案例主要实现对联系人的信息进行添加.显示.查找.删除.更新和保存功能.主要功能需求描述如下: (1)系统主控平台: 充许用户选择想要进行的操作,包括添加联系人信息,显示.查 ...
- Trie(前缀树)和ternary trie和binary search tree
1 什么是trie trie是一棵多叉树,假如存放的是由26个字母(不区分大小写)构成的字符串的话,那么就是一棵26叉树. trie树是一棵前缀树,因为每个结点只保存字符串中的一个字符,整个字符串保存 ...
- hdfs对namenode format 之后 应该首先检查内存消耗情况,以判断是否支持开启yarn
http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-common/yarn-default.xml 3.0.0 yarn.sc ...
- mysql 系统函数
SELECT VERSION() -- 获取 mysql版本号 SELECT CONNECTION_ID() -- 查看服务启动后 用户的连接次数 SELECT DATABASE(),SCHEMA() ...