本文整理汇总了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());
}