Android AIDL Object实现步骤
- 打包的对象类Rect实现android.os.Parcelable接口.
- 创建Rect.aidl填入如下代码:
-
package cn.lx; parcelable Rect; - 声明Service接口,RectService.aidl;必须import对应的打包类。
-
package cn.lx.aidl; import cn.lx.Rect; interface RectService{ cn.lx.Rect intersection(in cn.lx.Rect left,in cn.lx.Rect right); } - 实现RectService.Stub类中的方法.
- 在Service.onBind(Intent)返回RectService.Stub实现类的实例。