當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。