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

Android AIDL必看内容

 2010-05-27 03:49:00 来源:WEB开发网   
核心提示:mIsBound = true;mCallbackText.setText("Binding.");}};private OnClickListener mUnbindListener = new OnClickListener() {public void onClick(View v) {if

mIsBound = true;

mCallbackText.setText("Binding.");

}

};

private OnClickListener mUnbindListener = new OnClickListener() {

public void onClick(View v) {

if (mIsBound) {

// If we have received the service, and hence registered with

// it, then now is the time to unregister.

if (mService != null) {

try {

mService.unregisterCallback(mCallback);

} catch (RemoteException e) {

// There is nothing special we need to do if the service

// has crashed.

}

}

// Detach our existing connection.

unbindService(mConnection);

unbindService(mSecondaryConnection);

mKillButton.setEnabled(false);

mIsBound = false;

mCallbackText.setText("Unbinding.");

}

}

};

private OnClickListener mKillListener = new OnClickListener() {

public void onClick(View v) {

// To kill the process hosting our service, we need to know its

// PID. Conveniently our service has a call that will return

// to us that information.

if (mSecondaryService != null) {

try {

int pid = mSecondaryService.getPid();

// Note that, though this API allows us to request to

// kill any process based on its PID, the kernel will

// still impose standard restrictions on which PIDs you

// are actually able to kill. Typically this means only

// the process running your application and any additional

// processes created by that app as shown here; packages

// sharing a common UID will also be able to kill each

// other's processes.

Process.killProcess(pid);

mCallbackText.setText("Killed service process.");

} catch (RemoteException ex) {

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

Tags:Android AIDL

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