1、创建AIDL文件
2、在接口中写入两个抽象方法
// IBooklInterface.aidl
package com.example.fyq.broadtest;
import com.example.fyq.broadtest.Book;
// Declare any non-default types here with import statements
interface IBooklInterface {
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
List<Book> getBookList();
void addBook(in Book book);
}
3、由于Book是实现自Parcelable接口,所以需要再创建一个Book.aidl
// Book.aidl
package com.example.fyq.broadtest;
parcelable Book;//这里的Book类是自定义的Parcelable,因为IBook用到了自定义的,所以需要再创建一个Book.aidl
知识点:
AIDL最好放在同一个包中。