Service服务
2016-06-17 23:22
260 查看
一.特点
1.没有用户界面,在后台运行
2.应用退出后,Service还继续运行
3.默认情况下,在应用的主线程运行
4.应用重新启动,可以继续调用前面启动的Service
二.分类
1.本地服务:Service对象和启动者在同一个进程内;进程内通信。
2.远程服务:Service对象和启动者在不同的进程内;进程间通信,通过AIDL(Android接口定义语言 ) 来实现
三.实现
1.普通方式
2.绑定方式
普通方式的启动与停止代码展示:
.service
1.没有用户界面,在后台运行
2.应用退出后,Service还继续运行
3.默认情况下,在应用的主线程运行
4.应用重新启动,可以继续调用前面启动的Service
二.分类
1.本地服务:Service对象和启动者在同一个进程内;进程内通信。
2.远程服务:Service对象和启动者在不同的进程内;进程间通信,通过AIDL(Android接口定义语言 ) 来实现
三.实现
1.普通方式
2.绑定方式
普通方式的启动与停止代码展示:
package com.hanqi.testservice; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class MyService extends Service { public MyService() { Log.e("TAG","MyService被构造"); } //回调方法 //绑定 @Override public IBinder onBind(Intent intent) { // TODO: Return the communication channel to the service. throw new UnsupportedOperationException("Not yet implemented"); } }
.service
相关文章推荐
- 纯html实现下载图片
- Android之常用开发框架
- 利用python进行数据分析--(阅读笔记一)
- Oracle 11G RAC Interconnect IP Bendwidth Test
- 重启是“万能”的
- 27款经典的CSS框架
- linux网络编程----->线程同步-->信号量
- cocopods 学习、问题处理
- knight's
- c++补做作业2
- C++补做作业一
- 7个常见Javascript框架介绍
- Ionic开发中常见问题和解决方案记录
- Python 标准库 —— fractions
- 数据库练习题
- 解决KendoUI的kendoGrid行内新增时添加重复行
- 事件批量绑定器.on
- PHP常用框架
- c++补做作业1
- Linux平台卸载MySQL总结