android随笔service之二
2016-05-19 22:26
465 查看
独立进程
前面有说到Service默认的宿主进程就是当前App的进程,但是如果我现在有两个APP为了节省资源需要共享一个Service,那么我们可以将该Service设置为独立进程。
Service独立进程有两种,一种私有进程,一种是全局独立进程,这里我们需要设为全局独立进程;我们只需要在Manifest.xml里面配置Service的是设置android:process属性,例如:<Service name="xxx.yy" android:process="com.test"/>
如果我们有需求要将一个Service设为私有独立进程,则<Service name="xxx.yy" android:process=":test"/> 冒号:后面名字可自定义,这个时候系统会为这个Service开启一个名为:xxx.yy:test的进程。
IntentService
在我理解,IntentService就是相当于自己在普通Service中创建了一个新的线程来执行操作;当有新的启动请求的时候,请求会进入队列排队;当所有intent请求都处理完以后,该Service会自动关闭。
前面有说到Service默认的宿主进程就是当前App的进程,但是如果我现在有两个APP为了节省资源需要共享一个Service,那么我们可以将该Service设置为独立进程。
Service独立进程有两种,一种私有进程,一种是全局独立进程,这里我们需要设为全局独立进程;我们只需要在Manifest.xml里面配置Service的是设置android:process属性,例如:<Service name="xxx.yy" android:process="com.test"/>
如果我们有需求要将一个Service设为私有独立进程,则<Service name="xxx.yy" android:process=":test"/> 冒号:后面名字可自定义,这个时候系统会为这个Service开启一个名为:xxx.yy:test的进程。
IntentService
在我理解,IntentService就是相当于自己在普通Service中创建了一个新的线程来执行操作;当有新的启动请求的时候,请求会进入队列排队;当所有intent请求都处理完以后,该Service会自动关闭。
相关文章推荐
- 《Android View 的事件分发和滑动冲突》 —预习资料
- Android Studio 默认keystore 以及自定义keystore
- Android退出应用的方式
- Android基础知识:多媒体编程
- Android Handler机制
- Android Drawable - Layer Drawable使用详解(附图)
- Android studio Gradle icon error, Manifest Merger
- android安卓触摸事件touchEvent分发的 核心精辟代码
- Android TextView 显示不全的自动补齐方式
- Android Drawable Resources系列7:<inset>
- android布局
- Android ORMLite额框架
- Android Context完全解析
- Android md5加密工具类
- Notification用法,注意API版本,API大于11的setLatestEventInfo()方法已经不适用
- Android客户端,服务器,如何进行socket通讯的?
- android中ListView控件&&onItemClick事件中获取listView传递的数据
- EACCES (permission denied)解决办法 android 文件读写
- Android开发AsyncTask源码分析【模板方法模式】
- Android获取栈顶Activity/查看应用使用情况(适配Android6.0)