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


Java Context.CONNECTIVITY_SERVICE屬性代碼示例

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


在下文中一共展示了Context.CONNECTIVITY_SERVICE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: observeNetworkConnectivity

@Override public Observable<Connectivity> observeNetworkConnectivity(final Context context) {
    final String service = Context.CONNECTIVITY_SERVICE;
    final ConnectivityManager manager = (ConnectivityManager) context.getSystemService(service);
    networkCallback = createNetworkCallback(context);

    registerIdleReceiver(context);

    final NetworkRequest request =
            new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                    .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
                    .build();

    manager.registerNetworkCallback(request, networkCallback);

    return connectivitySubject.toFlowable(BackpressureStrategy.LATEST).doOnCancel(new Action() {
        @Override public void run() {
            tryToUnregisterCallback(manager);
            tryToUnregisterReceiver(context);
        }
    }).startWith(Connectivity.create(context)).distinctUntilChanged().toObservable();
}
 
開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:21,代碼來源:MarshmallowNetworkObservingStrategy.java

示例2: observeNetworkConnectivity

@Override public Observable<Connectivity> observeNetworkConnectivity(final Context context) {
    final String service = Context.CONNECTIVITY_SERVICE;
    final ConnectivityManager manager = (ConnectivityManager) context.getSystemService(service);

    return Observable.create(new ObservableOnSubscribe<Connectivity>() {
        @Override public void subscribe(ObservableEmitter<Connectivity> subscriber) throws Exception {
            networkCallback = createNetworkCallback(subscriber, context);
            final NetworkRequest networkRequest = new NetworkRequest.Builder().build();
            manager.registerNetworkCallback(networkRequest, networkCallback);
        }
    }).doOnDispose(new Action() {
        @Override public void run() {
            tryToUnregisterCallback(manager);
        }
    }).startWith(Connectivity.create(context)).distinctUntilChanged();
}
 
開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:16,代碼來源:LollipopNetworkObservingStrategy.java

示例3: getConnectivityManager

private static ConnectivityManager getConnectivityManager(Context context) {
    final String service = Context.CONNECTIVITY_SERVICE;
    return (ConnectivityManager) context.getSystemService(service);
}
 
開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:4,代碼來源:Connectivity.java

示例4: ConnectivityStub

public ConnectivityStub() {
    super(IConnectivityManager.Stub.asInterface, Context.CONNECTIVITY_SERVICE);
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:3,代碼來源:ConnectivityStub.java

示例5: ConnectivityPatch

public ConnectivityPatch() {
    super(IConnectivityManager.Stub.TYPE, Context.CONNECTIVITY_SERVICE);
}
 
開發者ID:codehz,項目名稱:container,代碼行數:3,代碼來源:ConnectivityPatch.java


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