congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ConnectivityManagerCompat
Code IndexAdd Tabnine to your IDE (free)

How to use
ConnectivityManagerCompat
in
android.support.v4.net

Best Java code snippets using android.support.v4.net.ConnectivityManagerCompat (Showing top 5 results out of 315)

origin: CarGuo/GSYVideoPlayer

public boolean isConnectionMetered() {
  if (mNoNetworkPermission) {
    return false;
  }
  return ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager);
}
origin: firebase/firebase-jobdispatcher-android

 /** Returns true if the currently active network is unmetered. */
 private static boolean isNetworkUnmetered(ConnectivityManager connectivityManager) {
  return !ConnectivityManagerCompat.isActiveNetworkMetered(connectivityManager);
 }
}
origin: evernote/android-job

boolean metered = ConnectivityManagerCompat.isActiveNetworkMetered(connectivityManager);
if (!metered) {
  return JobRequest.NetworkType.UNMETERED;
origin: antest1/kcanotify

public static boolean isMeteredNetwork(Context context) {
  ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  return (cm != null && ConnectivityManagerCompat.isActiveNetworkMetered(cm));
}
origin: henrichg/PhoneProfilesPlus

/**
 * Checks the network condition of the device and returns the best type. If the device
 * is connected to a WiFi and mobile network at the same time, then it would assume
 * that the connection is unmetered because of the WiFi connection.
 *
 * @param context Any context, e.g. the application context.
 * @return The current network type of the device.
 */
@NonNull
public static JobRequest.NetworkType getNetworkType(@NonNull Context context) {
  ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo networkInfo;
  try {
    networkInfo = connectivityManager.getActiveNetworkInfo();
  } catch (Throwable t) {
    return JobRequest.NetworkType.ANY;
  }
  if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
    return JobRequest.NetworkType.ANY;
  }
  boolean metered = ConnectivityManagerCompat.isActiveNetworkMetered(connectivityManager);
  if (!metered) {
    return JobRequest.NetworkType.UNMETERED;
  }
  if (networkInfo.isRoaming()) {
    return JobRequest.NetworkType.CONNECTED;
  } else {
    return JobRequest.NetworkType.NOT_ROAMING;
  }
}
android.support.v4.netConnectivityManagerCompat

Javadoc

Helper for accessing features in ConnectivityManager introduced after API level 16 in a backwards compatible fashion.

Most used methods

  • isActiveNetworkMetered
    Returns if the currently active data network is metered. A network is classified as metered when the

Popular in Java

  • Reading from database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Permission (java.security)
    Legacy security code; do not use.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now