added in version 22.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

ConnectivityManagerCompat

public final class ConnectivityManagerCompat
extends Object

java.lang.Object
   ↳ android.support.v4.net.ConnectivityManagerCompat


Helper for accessing features in ConnectivityManager.

Summary

Constants

int RESTRICT_BACKGROUND_STATUS_DISABLED

Device is not restricting metered network activity while application is running on background.

int RESTRICT_BACKGROUND_STATUS_ENABLED

Device is restricting metered network activity while application is running on background.

int RESTRICT_BACKGROUND_STATUS_WHITELISTED

Device is restricting metered network activity while application is running on background, but application is allowed to bypass it.

Public methods

static NetworkInfo getNetworkInfoFromBroadcast(ConnectivityManager cm, Intent intent)

Return the NetworkInfo that caused the given CONNECTIVITY_ACTION broadcast.

static int getRestrictBackgroundStatus(ConnectivityManager cm)

Determines if the calling application is subject to metered network restrictions while running on background.

static boolean isActiveNetworkMetered(ConnectivityManager cm)

Returns if the currently active data network is metered.

Inherited methods

From class java.lang.Object

Constants

RESTRICT_BACKGROUND_STATUS_DISABLED

added in version 25.1.0
int RESTRICT_BACKGROUND_STATUS_DISABLED

Device is not restricting metered network activity while application is running on background.

Constant Value: 1 (0x00000001)

RESTRICT_BACKGROUND_STATUS_ENABLED

added in version 25.1.0
int RESTRICT_BACKGROUND_STATUS_ENABLED

Device is restricting metered network activity while application is running on background.

In this state, application should not try to use the network while running on background, because it would be denied.

Constant Value: 3 (0x00000003)

RESTRICT_BACKGROUND_STATUS_WHITELISTED

added in version 25.1.0
int RESTRICT_BACKGROUND_STATUS_WHITELISTED

Device is restricting metered network activity while application is running on background, but application is allowed to bypass it.

In this state, application should take action to mitigate metered network access. For example, a music streaming application should switch to a low-bandwidth bitrate.

Constant Value: 2 (0x00000002)