当前位置: 首页>>代码示例>>Java>>正文


Java ConnectivityManagerCompat.isActiveNetworkMetered方法代码示例

本文整理汇总了Java中android.support.v4.net.ConnectivityManagerCompat.isActiveNetworkMetered方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectivityManagerCompat.isActiveNetworkMetered方法的具体用法?Java ConnectivityManagerCompat.isActiveNetworkMetered怎么用?Java ConnectivityManagerCompat.isActiveNetworkMetered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.net.ConnectivityManagerCompat的用法示例。


在下文中一共展示了ConnectivityManagerCompat.isActiveNetworkMetered方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNetworkType

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
/**
 * 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 = connectivityManager.getActiveNetworkInfo();
    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;
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:28,代码来源:Device.java

示例2: shouldWaitForWifi

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
public static boolean shouldWaitForWifi()
{
  if ((FinskyApp.get().mInstallPolicies.hasMobileNetwork()) && (!((Boolean)FinskyPreferences.autoUpdateWifiOnly.get()).booleanValue())) {
    return false;
  }
  InstallPolicies localInstallPolicies = FinskyApp.get().mInstallPolicies;
  if (localInstallPolicies.isWifiNetwork())
  {
    int j;
    if (InstallPolicies.SUPPORTS_MOBILE_HOTSPOT) {
      if ((localInstallPolicies.isWifiNetwork()) && (localInstallPolicies.mConnectivityManager.isActiveNetworkMetered())) {
        j = 1;
      }
    }
    while (j == 0)
    {
      return false;
      j = 0;
      continue;
      j = 0;
    }
  }
  if (UiUtils.isAndroidTv())
  {
    if ((localInstallPolicies.hasNetwork()) && (!ConnectivityManagerCompat.isActiveNetworkMetered(localInstallPolicies.mConnectivityManager))) {}
    for (int i = 1; i != 0; i = 0) {
      return false;
    }
  }
  return true;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:32,代码来源:ReschedulerStrategy.java

示例3: updateNetworkStatus

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
private void updateNetworkStatus(Intent intent) {
    mIsNetworkMetered = ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager);

    if (intent == null) {
        final NetworkInfo activeNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo == null) {
            mIsNetworkConnected = false;
        } else {
            mIsNetworkConnected = activeNetworkInfo.isConnected();
        }
    } else {
        mIsNetworkConnected = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
    }
}
 
开发者ID:CzBiX,项目名称:v2ex-android,代码行数:15,代码来源:DeviceStatus.java

示例4: isMeteredNetwork

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
public static boolean isMeteredNetwork(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    return (cm != null && ConnectivityManagerCompat.isActiveNetworkMetered(cm));
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:5,代码来源:Util.java

示例5: isOnMobile

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
public static boolean isOnMobile(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    return ConnectivityManagerCompat.isActiveNetworkMetered(cm);
}
 
开发者ID:M4lik,项目名称:burning-series,代码行数:7,代码来源:AndroidUtility.java

示例6: isConnectionMetered

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
public boolean isConnectionMetered() {
    if (mNoNetworkPermission) {
        return false;
    }
    return ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager);
}
 
开发者ID:CarGuo,项目名称:GSYVideoPlayer,代码行数:7,代码来源:NetInfoModule.java

示例7: isActiveNetworkMetered

import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
/**
 * 对大数据传输时,需要调用该方法做出判断,如果流量敏感,应该提示用户
 * 
 * @param context
 * @return true表示流量敏感,false表示不敏感
 */
public static boolean isActiveNetworkMetered(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    return ConnectivityManagerCompat.isActiveNetworkMetered(cm);
}
 
开发者ID:LiuJunb,项目名称:Android-LSS,代码行数:12,代码来源:NetworkUtils.java


注:本文中的android.support.v4.net.ConnectivityManagerCompat.isActiveNetworkMetered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。