BindService()
来源:互联网 发布:万隆版单片机课后答案 编辑:程序博客网 时间:2024/04/28 17:06
1.BindService()
bindService()构造方法
** @params service 指定调用的intent* @params conn ServiceConnection用于通信* @params flags 标记位*public boolean bindService(Intent service, ServiceConnection conn, int flags) {return mBase.bindService(service, conn, flags);}
2.继承onBind()方法
此方法会返回一个IBinder接口,得到IBinder接口的三种方式
- 继承Binder类
- 使用Messenger
- 使用AIDL
1.继承Binder类
@Overridepublic IBinder onBind(Intent intent) { //返回Binder对象 MyBind myBind = new MyBind(); return myBind;}//继承Binder类public class MyBind extends Binder { MyBindService getService() { return MyBindService.this; }}//在ServiceConnection使用private ServiceConnection connection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { MyBindService.MyBind myBind = (MyBindService.MyBind) service; MyBindService service = myBind.getService(); //就可以调用Service中的方法 } @Override public void onServiceDisconnected(ComponentName name) { }};
0 0
- bindService
- BindService
- BindService
- BindService
- BindService
- BindService
- bindService
- BindService
- BindService()
- 理解BindService
- BindService总结
- AIDL bindService
- bindservice用法
- 10 BindService
- bindService用法
- startService bindService
- BindService详解
- bindservice 理解
- tf_prefix的理解
- 跟我学JavaScript--typeof,null,undefined
- 继承一之继承方式
- 最长公共子序列(LCS)
- 使用遗传算法实现迷宫游戏(genetic maze)
- BindService()
- 移植lmdb到hi3519
- SpringMVC<from:form>表单标签和<input>表单标签简介
- 设计模式之组合模式
- 系统调用
- 学习网站收集
- mysql 5.7.17 源码安装
- JUNO版eclipse创建Java程序
- Python教程