本文整理匯總了Java中android.os.IBinder.isBinderAlive方法的典型用法代碼示例。如果您正苦於以下問題:Java IBinder.isBinderAlive方法的具體用法?Java IBinder.isBinderAlive怎麽用?Java IBinder.isBinderAlive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.IBinder
的用法示例。
在下文中一共展示了IBinder.isBinderAlive方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getService
import android.os.IBinder; //導入方法依賴的package包/類
/**
* 獲取已注冊的IBinder
*
* @param name
* @return
*/
public IBinder getService(final String name) {
if (LogDebug.LOG) {
LogDebug.d(TAG, "get service for IPlugin.query, name = " + name);
}
if (TextUtils.isEmpty(name)) {
throw new IllegalArgumentException("service name can not value null");
}
IBinder ret = mServices.get(name);
if (ret == null) {
return null;
}
if (!ret.isBinderAlive() || !ret.pingBinder()) {
mServices.remove(name);
return null;
}
return ret;
}
示例2: getService
import android.os.IBinder; //導入方法依賴的package包/類
@Override
public IBinder getService(String serviceName) throws RemoteException {
if (DEBUG) {
Log.d(TAG, "[getService] --> serviceName = " + serviceName);
}
if (TextUtils.isEmpty(serviceName)) {
throw new IllegalArgumentException();
}
IBinder service = sServices.get(serviceName);
// 若沒有注冊此服務,則嘗試從“延遲IBinder”中獲取
// Added by Jiongxuan Zhang
if (service == null) {
return fetchFromDelayedMap(serviceName);
}
// 判斷Binder是否掛掉
if (!service.isBinderAlive() || !service.pingBinder()) {
if (DEBUG) {
Log.d(TAG, "[getService] --> service died:" + serviceName);
}
sServices.remove(serviceName);
return null;
} else {
return service;
}
}
示例3: checkRemoteService
import android.os.IBinder; //導入方法依賴的package包/類
private boolean checkRemoteService() {
if (_remoteDataService == null) {
return false;
}
IBinder iBinder = _remoteDataService.asBinder();
if (iBinder == null) {
return false;
}
if (!iBinder.isBinderAlive()) {
return false;
}
return true;
}
示例4: getService
import android.os.IBinder; //導入方法依賴的package包/類
/**
* 獲取已注冊服務的IBinder對象,前提是該服務是靜態服務,即默認一直存在,或者自己已經啟動並且向我們注冊過;
* 注意不能通過此借口獲取一個插件的服務,除非明確知道該插件的服務已經主動注冊過,否則使用getPluginService()
*
* @param context
* @param serviceName 請求獲取的service名稱
* @return 所請求的service實現對象
*/
public static IBinder getService(Context context, String serviceName) {
if (DEBUG) {
Log.d(TAG, "[getService] begin = " + SystemClock.elapsedRealtime());
}
IBinder service = null;
/**
* 先考慮本地緩存
*/
SoftReference<IBinder> ref = sCache.get(serviceName);
if (ref != null) {
service = ref.get();
if (service != null) {
if (service.isBinderAlive() && service.pingBinder()) {
if (DEBUG) {
Log.d(TAG, "[getService] Found service from cache: " + serviceName);
Log.d(TAG, "[getService] end = " + SystemClock.elapsedRealtime());
}
return service;
} else {
sCache.remove(serviceName);
}
}
}
IServiceChannel serviceChannel = getServerChannel(context);
if (serviceChannel == null) {
return null;
}
try {
service = serviceChannel.getService(serviceName);
if (service != null) {
if (DEBUG) {
Log.d(TAG, "[getService] Found service from remote service channel: " + serviceName);
}
service = ServiceWrapper.factory(context, serviceName, service);
sCache.put(serviceName, new SoftReference<IBinder>(service));
}
} catch (RemoteException e) {
if (DEBUG) {
Log.e(TAG, "[getService] Error when getting service from service channel...", e);
}
}
if (DEBUG) {
Log.d(TAG, "[getService] end = " + SystemClock.elapsedRealtime());
}
return service;
}
示例5: isAlive
import android.os.IBinder; //導入方法依賴的package包/類
public static boolean isAlive(IBinder binder){
return (binder!=null && binder.isBinderAlive() && binder.pingBinder());
}