本文整理汇总了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;
}
}
示例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;
}
示例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);
}
}
示例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));
}
示例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);
}
示例6: isConnectionMetered
import android.support.v4.net.ConnectivityManagerCompat; //导入方法依赖的package包/类
public boolean isConnectionMetered() {
if (mNoNetworkPermission) {
return false;
}
return ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager);
}
示例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);
}