當前位置: 首頁>>代碼示例>>Java>>正文


Java IBinder.pingBinder方法代碼示例

本文整理匯總了Java中android.os.IBinder.pingBinder方法的典型用法代碼示例。如果您正苦於以下問題:Java IBinder.pingBinder方法的具體用法?Java IBinder.pingBinder怎麽用?Java IBinder.pingBinder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.IBinder的用法示例。


在下文中一共展示了IBinder.pingBinder方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:29,代碼來源:RePluginServiceManager.java

示例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;
    }
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:31,代碼來源:ServiceChannelImpl.java

示例3: 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;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:62,代碼來源:QihooServiceManager.java

示例4: isAlive

import android.os.IBinder; //導入方法依賴的package包/類
public static boolean isAlive(IBinder binder){
    return (binder!=null && binder.isBinderAlive() && binder.pingBinder());
}
 
開發者ID:devyok,項目名稱:IPCServiceManager,代碼行數:4,代碼來源:Utils.java


注:本文中的android.os.IBinder.pingBinder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。