Android-Service
来源:互联网 发布:手机焓湿图计算软件 编辑:程序博客网 时间:2024/06/07 06:19
1、问题列表
1.1、service是运行在一个单独的线程?
官方原文:
Caution: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work. By using a separate thread, you will reduce the risk of Application Not Responding (ANR) errors and the application's main thread can remain dedicated to user interaction with your activities.
并不是运行在一个单独的线程的,是运行在启动他的组件的主线程上的。所以如果我们需要在service中做一些耗时的操作,需要自己另外启一个线程。
1.2、service可以同时被startService()和bindService()启动吗?
官方原文:These two paths are not entirely separate. That is, you can bind to a service that was already started with
startService()
. For example, a background music service could be started by calling startService()
with anIntent
that identifies the music to play. Later, possibly when the user wants to exercise some control over the player or get information about the current song, an activity can bind to the service by calling bindService()
. In cases like this, stopService()
or stopSelf()
does not actually stop the service until all clients unbind.一个service可以同时被startService()和bindService()
1.2、service的声明周期
2、demo
2.1、范德萨
3、相关链接
3.1、官方
Guide(Service):http://developer.android.com/guide/components/services.html#Notifications
Guide(BoundService):http://developer.android.com/guide/components/bound-services.html
3.2、网友
0 0
- [android]service中再启service
- android service
- Android Service
- android service
- Android Service
- Android service
- android service
- Android Service
- Android Service
- Android service
- Android:Service
- Android Service
- [Android] Service
- android service
- android service
- android service
- android service
- Android Service
- iOS开发UI篇—自定义瀑布流控件(蘑菇街瀑布流)
- 使用springMVC框架的相关配置文件
- 两个int值的交换
- hercules配置TCPIP(os390 2.10 DEMOPKG)
- Hibernate主键生成策略和持久化对象的三种状态和MySql常用的数据库语句
- Android-Service
- 母函数 整数拆分 (hdu 1028 , poj 1221)
- 用vs12做个黑框框
- LPCTSTR、LPSTR与LPTSTR
- iOS开发UI篇—自定义瀑布流控件(蘑菇街数据刷新操作)
- Hibernate-Validation的使用
- Android WebView详解之JS调用Java方法
- Eclipse开发环境搭建
- 网站优化之长尾关键词的弯道超越