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,這一篇文章就夠了(上)