WEB开发网
开发学院手机开发Android 开发 Android AIDL必看内容 阅读

Android AIDL必看内容

 2010-05-27 03:49:00 来源:WEB开发网   
核心提示:Explorer view视图上单击鼠标右键,选择Create Aidl preprocess file for Parcelable classes(创建aidl预编译文件),Android AIDL必看内容(2),最终我们创建一个名为android123.aidl文件import android.os.Parcel
Explorer view视图上单击鼠标右键,选择Create Aidl preprocess file for Parcelable classes(创建aidl预编译文件),最终我们创建一个名为android123.aidl文件

import android.os.Parcel;

import android.os.Parcelable;

public final class Rect implements Parcelable {

public int left;

public int top;

public int right;

public int bottom;

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

public Rect createFromParcel(Parcel in) {

return new Rect(in);

}

public Rect[] newArray(int size) {

return new Rect[size];

}

};

public Rect() {

}

private Rect(Parcel in) {

readFromParcel(in);

}

public void writeToParcel(Parcel out) { //当前数据写入到Parcel中

out.writeInt(left);

out.writeInt(top);

out.writeInt(right);

out.writeInt(bottom);

}

public void readFromParcel(Parcel in) { //从Parcel中读取数据

left = in.readInt();

top = in.readInt();

right = in.readInt();

bottom = in.readInt();

}

}

IPC调用方式

public class RemoteServiceBinding extends Activity {

/** The primary interface we will be calling on the service. */

IRemoteService mService = null;

/** Another interface we use on the service. */

ISecondary mSecondaryService = null;

Button mKillButton;

TextView mCallbackText;

private boolean mIsBound;

/**

* Standard initialization of this activity. Set up the UI, then wait

* for the user to poke it before doing anything.

*/

@Override

protected void onCreate(Bundle savedInstanceState) {

上一页  1 2 3 4 5 6  下一页

Tags:Android AIDL

编辑录入:coldstar [复制链接] [打 印]
赞助商链接