---
title: "Android AIDL Object实现步骤"
author: "L.x"
date: "2012-02-10T17:44:51Z"
tags: ["AIDL", "Java", "adnroid"]
categories: ["移动开发"]
slug: "android-aidl-object"
draft: false
lastmod: "2012-02-10T17:45:50Z"
id: 1402231
url: "https://l-x.iteye.com/blog/1402231"
---

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