Android AIDL基本知识点:
(1)Android AIDL 概述
- 什么是AIDL
- AIDL能实现什么功能
(2)Defining an AIDL Interface 三步
- Create the .aidl file
- Implement the interface
- Expose the interface to clients
(3)AIDL supports data types
- 基本类型 such as int, long, char, boolean, and so on
- Map、List
- CharSequence
(4)Passing Objects over IPC 四步
1.类继承Parcelable 接口
2.实现 writeToParcel 方法
3.添加继承了Parcelable.Creator 的静态成员变量 CREATOR
4.创建AIDL文件,声明创建的parcelable 类
(5)Calling an IPC Method 七步
1.添加AIDL文件
2.声明IBinder接口
3.实现ServiceConnection 接口
4.调用context.bindService方法
5.在onServiceConnected()方法中接收IBinder实例
6.调用在接口中定义的方法
7.调用context.unbindService()断开连接
备注:
1. 跨进程中,对象是被认为引用的
2. 可以把匿名的对象作为方法的参数
参考文档:
(1)、官方GUIDE
(2)、Android:学习AIDL,这一篇文章就够了(上)