2019独角兽企业重金招聘Python工程师标准>>>

As discussed in the Services document, you can create a service that is both started and bound. That is, the service can be started by calling startService(), which allows the service to run indefinitely, and also allow a client to bind to the service by calling bindService().

If you do allow your service to be started and bound, then when the service has been started, the system does not destroy the service when all clients unbind. Instead, you must explicitly stop the service, by calling stopSelf() or stopService().

Although you should usually implement either onBind() or onStartCommand(), it's sometimes necessary to implement both. For example, a music player might find it useful to allow its service to run indefinitely and also provide binding. This way, an activity can start the service to play some music and the music continues to play even if the user leaves the application. Then, when the user returns to the application, the activity can bind to the service to regain control of playback.

Be sure to read the section about Managing the Lifecycle of a Bound Service, for more information about the service lifecycle when adding binding to a started service

转载于:https://my.oschina.net/wrs/blog/270891

Activity和Service交互相关推荐

  1. android service交互,Android Activity与Service的交互方式

    参考: http://blog.csdn.net/gebitan505/article/details/18151203 实现更新下载进度的功能 1. 通过广播交互 Server端将目前的下载进度,通 ...

  2. [转]Android中程序与Service交互的方式——交互方式

    本文转自:http://blog.csdn.net/yihongyuelan/article/details/7216188 上一篇文章:Android中程序与Service交互的方式--综述 简述了 ...

  3. Android Activity与Service的交互方式

    1. 通过广播交互 Server端将目前的下载进度,通过广播的方式发送出来,Client端注册此广播的监听器,当获取到该广播后,将广播中当前的下载进度解析出来并更新到界面上. 优缺点分析: 通过广播的 ...

  4. Android中Service的启动方式及Activity与Service的通信方式

    Service启动的两种方式 1.通过startService启动 使用Service的步骤: 定义一个类继承Service 在Manifest.xml文件中配置该Service 使用Context的 ...

  5. 安卓基础巩固(二):四大组件:Activity、Service、Broadcast、Content Provider

    文章目录 Activity 生命周期 onCreate和onStart的区别 onPause和onStop的区别 生命周期的变化 Activity的启动 Intent Bundle Activity携 ...

  6. Android基础再回首——四大组件之Activity、Service俩兄弟

    Android基础再回首--四大组件之Activity.Service俩兄弟 偶尔的回首过去,总是有不一样的收获.今天就来回顾下Activity和service吧,不用嫌弃太基础了,打好基础是取得成功 ...

  7. android app渗透测试-Activity、Service

    Android App中可能出现的安全漏洞的类型: 协议--通信协议(本地.网络),协议大部分是由C/C++实现,存在以下安全问题:通信数据引发的逻辑漏洞:通信数据引发的缓冲区溢出等可能导致远程代码执 ...

  8. Android中程序与Service交互的方式

    本文将通过三大部分来讲解Android中程序与Service的交互方式,这里说的交互方式指的是如何与Service进行消息的传递,比如:从Service中获取信息,向Service发送信息等等.举个简 ...

  9. Android 四大组件(Activity、Service、BroadCastReceiver、ContentProvider)

    Android四大基本组件分别是Activity,Service服务,Content Provider内容提供者,BroadcastReceiver广播接收器. 一.了解四大基本组件 Activity ...

最新文章

  1. matlab将二值图像与原图重叠_[转载]图像处理matlab及图像融合图像镶嵌图像拼接...
  2. android上使用蓝牙设备进行语音输入
  3. 关于w3wp.exe
  4. 开源硬件 专利_标准和开源:为什么专利待遇不同?
  5. linux 修改自动联网的配置说明
  6. linux中删除svn中文件,删除SVN三种方法delSvn(windows+linux)
  7. tomcat设置错误页面
  8. 反转链表的Java实现
  9. 提前体验让人回归Windows怀抱的Windows Terminal
  10. 1114 计算营业额
  11. wps公式编辑器文字和公式不对齐
  12. df pd 属性_DataFrame 常用方法属性
  13. 通过antd-charts可视化对比科比和詹姆斯谁更强
  14. 放置街灯(UVA 10859)
  15. html崩溃手机代码15,这12行代码分分钟让你电脑崩溃手机重启
  16. EasyMock 单元测试
  17. 【youcans 的图像处理学习课】22. Haar 级联分类器
  18. SparkRDD——行动算子
  19. ITE sdK自定义事件接收流程
  20. Zircon 与 LK

热门文章

  1. matlab 分隔线,matlab字符分割方法
  2. java多态的两种形式_java核心(八):继承与方法重写、final、多态性的两种描述形式...
  3. 如何修改linux的java路径_修改桌面文件默认存储位置的正确方式及注意事项
  4. swool tcp mysql_swoole/mysql(异步)
  5. .net 实时通信_【WebSocket】实时多人答题对战游戏
  6. opencv java 去干扰_java - OpenCV Java修补图像格式要求 - 堆栈内存溢出
  7. 网页自动关机代码HTML,win10系统打开邮件显示网页html源代码如何解决
  8. idea springboot热部署无效问题
  9. 你的main函数规范吗?
  10. 树莓派4B (aarch64) 安装PyTorch 1.8 的可行方案