一. BluetoothDevice简介
1. 继承关系
public static Class BluetoothDevice extends Object implement Parcelable
该类实现了Parcelable接口, 实现了Parcelable接口的类的对象可以封装到Parcel对象中, 封装后的数据可以通过Intent或者IPC传递;
实现Parcelable接口要点 :
a. 实现writeTpParcl()方法 : 将数据写入到Parcel对象中;
public void writeToParcel(Parcel out, int arg1) { // TODO Auto-generated method stub out.writeBundle(this.mBundle); }
b. 实现describeContents()方法 :
public int describeContents() { // TODO Auto-generated method stub return 0; }
c.实现Parcelable.Creator接口 :
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public TrainInfo createFromParcel(Parcel in) { SampleBean ti=new SampleBean(); ti.mBundle=in.readBundle(); return ti; } public SampleBean[] newArray(int size) { return new SampleBean[size]; } };
2. 该类简介
BluetoothDevice对象代表了一个远程的蓝牙设备, 通过这个类可以查询远程设备的物理地址, 名称, 连接状态等信息;