aidlカスタムタイプ


BtDevice.java

package com.example.aidl_service;

import android.os.Parcel;
import android.os.Parcelable;

public class BtDevice implements Parcelable{
	
	private int id;
	private String  device;
	
	public BtDevice() {
		// TODO Auto-generated constructor stub
	}
	
	public BtDevice(int readInt, String readString) {
		// TODO Auto-generated constructor stub
		this.id=readInt;
		this.device=readString;
	}
	
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		
		dest.writeInt(id);
		dest.writeString(device);
	}
	
	public static final Parcelable.Creator<BtDevice> CREATOR=new Creator<BtDevice>() {
		
		@Override
		public BtDevice[] newArray(int size) {
			// TODO Auto-generated method stub
			return new BtDevice[size];
		}
		
		@Override
		public BtDevice createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new BtDevice(source.readInt(),source.readString());
		}
	};
	

}


BtDevice.aidl

package com.example.aidl_service;
parcelable BtDevice;

MyAidl.aidl

package com.example.aidl_service;

import java.util.List;

import android.bluetooth.BluetoothDevice;

import com.example.aidl_service.BtDevice;

interface MyAidl {
	
	String getStr();
	
	String getStr2(String str);
	
	List<BluetoothDevice> getBT();
	
	String getDevice(in BluetoothDevice device);
	
	BtDevice getDevice2(in BtDevice btDevice);
	
}

BtDeviceを生成したaidlのjavaファイルと一緒にクライアントにコピーするのを忘れないでください.