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

Android AIDL必看内容

 2010-05-27 03:49:00 来源:WEB开发网   
核心提示:// Recover gracefully from the process hosting the// server dying.// Just for purposes of the sample, put up a notification.Toast.makeText(RemoteServiceBinding.

// Recover gracefully from the process hosting the

// server dying.

// Just for purposes of the sample, put up a notification.

Toast.makeText(RemoteServiceBinding.this,

R.string.remote_call_failed,

Toast.LENGTH_SHORT).show();

}

}

}

};

// ----------------------------------------------------------------------

// Code showing how to deal with callbacks.

// ----------------------------------------------------------------------

/**

* This implementation is used to receive callbacks from the remote

* service.

*/

private IRemoteServiceCallback mCallback = new IRemoteServiceCallback.Stub() {

/**

* This is called by the remote service regularly to tell us about

* new values. Note that IPC calls are dispatched through a thread

* pool running in each process, so the code executing here will

* NOT be running in our main thread like most other things -- so,

* to update the UI, we need to use a Handler to hop over there.

*/

public void valueChanged(int value) {

mHandler.sendMessage(mHandler.obtainMessage(BUMP_MSG, value, 0));

}

};

private static final int BUMP_MSG = 1;

private Handler mHandler = new Handler() {

@Override public void handleMessage(Message msg) {

switch (msg.what) {

case BUMP_MSG:

mCallbackText.setText("Received from service: " + msg.arg1);

break;

default:

super.handleMessage(msg);

}

}

};

}

上一页  1 2 3 4 5 6 

Tags:Android AIDL

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