本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}