Example usage for android.net NetworkCapabilities hasCapability

List of usage examples for android.net NetworkCapabilities hasCapability

Introduction

In this page you can find the example usage for android.net NetworkCapabilities hasCapability.

Prototype

public boolean hasCapability(@NetCapability int capability) 

Source Link

Document

Tests for the presence of a capability on this instance.

Usage

From source file:androidx.work.impl.constraints.trackers.NetworkStateTracker.java

private boolean isActiveNetworkValidated() {
    if (Build.VERSION.SDK_INT < 23) {
        return false; // NET_CAPABILITY_VALIDATED not available until API 23. Used on API 26+.
    }//from  ww  w .  ja v a 2 s  . c  o m
    Network network = mConnectivityManager.getActiveNetwork();
    NetworkCapabilities capabilities = mConnectivityManager.getNetworkCapabilities(network);
    return capabilities != null && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
}