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


Java NetworkInfo.getExtraInfo方法代码示例

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


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

示例1: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络
 */
public static int getNetworkType(Context context) {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (extraInfo != null && !extraInfo.isEmpty()) {
            if (extraInfo.equalsIgnoreCase("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:28,代码来源:DeviceUtils.java

示例2: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络
 */
public static int getNetworkType(Context context) {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (!TextUtils.isEmpty(extraInfo)) {
            if (extraInfo.toLowerCase(Locale.getDefault()).equals("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:28,代码来源:CommonUtils.java

示例3: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络
 */
public static int getNetworkType() {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) AppContext
            .getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (!TextUtils.isEmpty(extraInfo)) {
            if (extraInfo.toLowerCase().equals("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:29,代码来源:TDevice.java

示例4: isCmwap

import android.net.NetworkInfo; //导入方法依赖的package包/类
private static boolean isCmwap(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService("phone");
    if (tm == null) {
        return false;
    }
    if (!"CN".equalsIgnoreCase(tm.getSimCountryIso())) {
        return false;
    }
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService("connectivity");
    if (cm == null) {
        return false;
    }
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null) {
        return false;
    }
    String extraInfo = info.getExtraInfo();
    if (TextUtils.isEmpty(extraInfo) || extraInfo.length() < 3 || extraInfo.contains("ctwap")) {
        return false;
    }
    return extraInfo.regionMatches(true, extraInfo.length() - 3, "wap", 0, 3);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:Network.java

示例5: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static String getNetworkType(Context context) {
    String networkType = EnvironmentCompat.MEDIA_UNKNOWN;
    if (context == null) {
        LOG.w(TAG, "get network type failed(null context)");
        return networkType;
    }
    ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService("connectivity");
    if (connMgr == null) {
        LOG.e(TAG, "get connectivity manager failed");
        return networkType;
    }
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo == null) {
        return networkType;
    }
    String typeName = networkInfo.getTypeName();
    String subTypeName = networkInfo.getSubtypeName();
    String extraInfo = networkInfo.getExtraInfo();
    if (TextUtils.isEmpty(subTypeName)) {
        networkType = typeName + "/" + extraInfo;
    } else {
        networkType = typeName + "(" + subTypeName + ")/" + extraInfo;
    }
    return networkType;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:SystemUtils.java

示例6: a

import android.net.NetworkInfo; //导入方法依赖的package包/类
private static HttpURLConnection a(Context context, String str) {
    try {
        URL url = new URL(str);
        if (context.getPackageManager().checkPermission(z[43], context.getPackageName()) == 0) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(z[44])).getActiveNetworkInfo();
            if (!(activeNetworkInfo == null || activeNetworkInfo.getType() == 1)) {
                String extraInfo = activeNetworkInfo.getExtraInfo();
                if (extraInfo != null && (extraInfo.equals(z[40]) || extraInfo.equals(z[41]) || extraInfo.equals(z[42]))) {
                    return (HttpURLConnection) url.openConnection(new Proxy(Type.HTTP, new InetSocketAddress(z[45], 80)));
                }
            }
        }
        return (HttpURLConnection) url.openConnection();
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e2) {
        e2.printStackTrace();
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:p.java

示例7: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络   1:WIFI网络   2:WAP网络    3:NET网络
 */
public static int getNetworkType(Context ctx) {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (!TextUtils.isEmpty(extraInfo)) {
            if (extraInfo.toLowerCase().equals("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:28,代码来源:NetworkUtils.java

示例8: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络
 */
public static int getNetworkType(Context context) {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (extraInfo != null && !extraInfo.isEmpty()) {
            if (extraInfo.equalsIgnoreCase("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:28,代码来源:DeviceUtils.java

示例9: isCtwap

import android.net.NetworkInfo; //导入方法依赖的package包/类
private static boolean isCtwap(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService("phone");
    if (tm == null) {
        return false;
    }
    if (!"CN".equalsIgnoreCase(tm.getSimCountryIso())) {
        return false;
    }
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService("connectivity");
    if (cm == null) {
        return false;
    }
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null) {
        return false;
    }
    String extraInfo = info.getExtraInfo();
    if (TextUtils.isEmpty(extraInfo) || extraInfo.length() < 3) {
        return false;
    }
    return extraInfo.contains("ctwap");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:Network.java

示例10: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static int getNetworkType() {
    NetworkInfo networkInfo = ((ConnectivityManager) mContext.getSystemService
            ("connectivity")).getActiveNetworkInfo();
    if (networkInfo == null) {
        return 0;
    }
    int nType = networkInfo.getType();
    if (nType == 0) {
        String extraInfo = networkInfo.getExtraInfo();
        if (isEmpty(extraInfo)) {
            return 0;
        }
        if (extraInfo.toLowerCase().equals("cmnet")) {
            return 3;
        }
        return 2;
    } else if (nType == 1) {
        return 1;
    } else {
        return 0;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:LEYUApplication.java

示例11: getNetworkType

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前网络类型
 *
 * @return 0:没有网络 1:WIFI网络 2:WAP网络 3:NET网络
 */
public static int getNetworkType(Context context) {
    int netType = 0;
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null) {
        return netType;
    }
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_MOBILE) {
        String extraInfo = networkInfo.getExtraInfo();
        if (extraInfo != null && !extraInfo.isEmpty()) {
            if (extraInfo.toLowerCase().equals("cmnet")) {
                netType = NETTYPE_CMNET;
            } else {
                netType = NETTYPE_CMWAP;
            }
        }
    } else if (nType == ConnectivityManager.TYPE_WIFI) {
        netType = NETTYPE_WIFI;
    }
    return netType;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:DeviceUtils.java

示例12: getApn

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * 获取当前移动网络APN名字
 *
 * @param context 上下文
 *
 * @return APN
 */
public static String getApn(Context context) {
	try {
		//			if (!PermissionUtils.isPermissionGranted(context, Manifest.permission.ACCESS_NETWORK_STATE)) {
		//				return APN.APN_UNKNOW;
		//			}
		ConnectivityManager connectivityManager =
				(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
		if (activeNetworkInfo != null) {
			if (activeNetworkInfo.isAvailable()) {
				switch (activeNetworkInfo.getType()) {
				case ConnectivityManager.TYPE_WIFI: // wifi网络
					return APN.APN_WIFI;
				case ConnectivityManager.TYPE_MOBILE: // 手机网络
					// 判断接入点
					String apn = activeNetworkInfo.getExtraInfo();
					if (apn != null) {
						apn = apn.trim().toLowerCase();
						if (apn.length() > 25) {
							return apn.substring(0, 25);
						} else {
							return apn;
						}
					} else {
						// 未知接入点,返回 APN_UNKNOW
						return APN.APN_UNKNOW;
					}
				default:
					break;
				}
			}
		}
	} catch (Throwable e) {
		DLog.e(e);
	}
	return APN.APN_UNKNOW;
}
 
开发者ID:youmi,项目名称:nativead,代码行数:45,代码来源:NetworkUtils.java

示例13: b

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static boolean b(Context context) {
    if (!"CN".equalsIgnoreCase(((TelephonyManager) context.getSystemService("phone"))
            .getSimCountryIso())) {
        return false;
    }
    try {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService("connectivity");
        if (connectivityManager == null) {
            return false;
        }
        try {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null) {
                return false;
            }
            String extraInfo = activeNetworkInfo.getExtraInfo();
            return (TextUtils.isEmpty(extraInfo) || extraInfo.length() < 3 || extraInfo
                    .contains("ctwap")) ? false : extraInfo.regionMatches(true, extraInfo
                    .length() - 3, "wap", 0, 3);
        } catch (Exception e) {
            return false;
        }
    } catch (Exception e2) {
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:d.java

示例14: getConnectionInfo

import android.net.NetworkInfo; //导入方法依赖的package包/类
/**
 * Get the latest network connection information
 *
 * @param info the current active network info
 * @return a JSONObject that represents the network info
 */
private JSONObject getConnectionInfo(NetworkInfo info) {
    String type = TYPE_NONE;
    String extraInfo = "";
    if (info != null) {
        // If we are not connected to any network set type to none
        if (!info.isConnected()) {
            type = TYPE_NONE;
        }
        else {
            type = getType(info);
        }
        extraInfo = info.getExtraInfo();
    }

    LOG.d(LOG_TAG, "Connection Type: " + type);
    LOG.d(LOG_TAG, "Connection Extra Info: " + extraInfo);

    JSONObject connectionInfo = new JSONObject();

    try {
        connectionInfo.put("type", type);
        connectionInfo.put("extraInfo", extraInfo);
    } catch (JSONException e) {
        LOG.d(LOG_TAG, e.getLocalizedMessage());
    }

    return connectionInfo;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:35,代码来源:NetworkManager.java

示例15: E

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static String E(Context context) {
    String str = "";
    try {
        if (r.a(context, "android.permission.INTERNET") && r.a(context, "android.permission" +
                ".ACCESS_NETWORK_STATE")) {
            String typeName;
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService
                    ("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
                typeName = activeNetworkInfo.getTypeName();
                String extraInfo = activeNetworkInfo.getExtraInfo();
                if (typeName != null) {
                    if (typeName.equalsIgnoreCase("WIFI")) {
                        return "WIFI";
                    }
                    if (typeName.equalsIgnoreCase("MOBILE")) {
                        return extraInfo != null ? extraInfo : "MOBILE";
                    } else {
                        if (extraInfo != null) {
                            return extraInfo;
                        }
                        return typeName;
                    }
                }
            }
            typeName = str;
            return typeName;
        }
        cT.d("can not get the permission of android.permission.ACCESS_WIFI_STATE");
        return str;
    } catch (Throwable th) {
        cT.b(th);
        return str;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:36,代码来源:l.java


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