关于AIDL与回调的一些记录

一、import com.rt.bluetooth.utity.TelContact;
interface IBluetoothServiceCallBacks {
void callback(String name);
void getPhoneBooks( inout List<TelContact> list);
void getDriviceName(String driviceName);
void getDrivicePin(String drivicePin);
void getContacts( inout List<TelContact> list);
void getBtStates(int state);
void getPhoneNum(String num);
void getMusicStates(boolean flag);
void getCount(int count);
void getPhoneBook(in TelContact telContact);
void getContact(in TelContact telContact);
void getPhoneBooksadd( inout List<TelContact> list,int flag);
}
二、public class TelContact implements Parcelable {


public static String TAG = "TelContact";
private String name;
private String num;
private String time;
private String type;


public String getTime() {
return time;
}

public void setTime(String time) {
this.time = time;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}


public TelContact() {
super();
}

public TelContact(String name, String num, String time, String type) {
super();
this.name = name;
this.num = num;
this.time = time;
this.type = type;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}


public String getNum() {
return num;
}

public void setNum(String num) {
this.num = num;
}

// 测试用

// 以下为aidl传递对象需要的操作
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}


@Override
public String toString() {
return "TelContact [name=" + name + ", num=" + num + ", time=" + time
+ ", type=" + type + "]";
}


@Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
dest.writeString(name);
dest.writeString(num);
dest.writeString(time);
dest.writeString(type);

}


public static final Parcelable.Creator<TelContact> CREATOR = new Creator<TelContact>() {


@Override
public TelContact createFromParcel(Parcel source) {
String name = source.readString();
String num = source.readString();
String time = source.readString();
String type = source.readString();
TelContact telContact = new TelContact();
telContact.setName(name);
telContact.setNum(num);
telContact.setTime(time);
telContact.setType(type);


return telContact;
}


@Override
public TelContact[] newArray(int size) {
return new TelContact[size];
}


};


}
parcelable TelContact;
三、private RemoteCallbackList <IBluetoothServiceCallBacks> mCallbacks = new RemoteCallbackList <IBluetoothServiceCallBacks>(); 
四、@Override
public void registerCallback(IBluetoothServiceCallBacks callBack)
throws RemoteException {
// TODO Auto-generated method stub
RTLogUtils.i(TAG, "注册registerCallback1="+callBack);
if(callBack!=null){
RTLogUtils.i(TAG, "注册registerCallback2="+callBack);
mCallbacks.register(callBack);
BtApplication.callBacks = callBack;
RTLogUtils.i(TAG, "BtApplication.callBacks注册"+BtApplication.callBacks);

RTLogUtils.i(TAG, BtApplication.deviceName+";"+BtApplication.devicePin);
callBack.getDriviceName(BtApplication.deviceName);
callBack.getDrivicePin(BtApplication.devicePin);
}
}
五、interface IBluetoothService {

void registerCallback(IBluetoothServiceCallBacks callBack);

void unregisterCallback(IBluetoothServiceCallBacks callBack);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值