List of usage examples for android.net NetworkInfo getSubtypeName
@Deprecated
public String getSubtypeName()
From source file:Main.java
public static String getcurrentNetworkNoWifi(Context context) { String network_type = "UNKNOWN";// maybe usb reverse tethering NetworkInfo active_network = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();/*ww w .j a v a 2 s. c o m*/ if (active_network != null && active_network.isConnectedOrConnecting()) { network_type = active_network.getSubtypeName(); } return network_type; }
From source file:Main.java
public static String[] getNetworkState(Context pContext) { String[] type = new String[2]; type[0] = "Unknown"; type[1] = "Unknown"; if (pContext.getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", pContext.getPackageName()) == PackageManager.PERMISSION_GRANTED) { ConnectivityManager localConnectivityManager = (ConnectivityManager) pContext .getSystemService("connectivity"); if (localConnectivityManager == null) return type; NetworkInfo localNetworkInfo1 = localConnectivityManager.getNetworkInfo(1); if ((localNetworkInfo1 != null) && (localNetworkInfo1.getState() == NetworkInfo.State.CONNECTED)) { type[0] = "Wi-Fi"; type[1] = localNetworkInfo1.getSubtypeName(); return type; }//from w w w. ja v a 2 s. co m NetworkInfo localNetworkInfo2 = localConnectivityManager.getNetworkInfo(0); if ((localNetworkInfo2 == null) || (localNetworkInfo2.getState() != NetworkInfo.State.CONNECTED)) type[0] = "2G/3G"; type[1] = localNetworkInfo2.getSubtypeName(); return type; } return type; }
From source file:Main.java
public static String[] getNetType(Context paramContext) { String[] arrayOfString = { "Unknown", "Unknown" }; PackageManager localPackageManager = paramContext.getPackageManager(); if (localPackageManager.checkPermission("android.permission.ACCESS_NETWORK_STATE", paramContext.getPackageName()) != 0) { arrayOfString[0] = "Unknown"; return arrayOfString; }/*from w w w .jav a2 s . c o m*/ ConnectivityManager localConnectivityManager = (ConnectivityManager) paramContext .getSystemService("connectivity"); if (localConnectivityManager == null) { arrayOfString[0] = "Unknown"; return arrayOfString; } NetworkInfo localNetworkInfo1 = localConnectivityManager.getNetworkInfo(1); if (localNetworkInfo1 != null && localNetworkInfo1.getState() == NetworkInfo.State.CONNECTED) { arrayOfString[0] = "2"; return arrayOfString; } NetworkInfo localNetworkInfo2 = localConnectivityManager.getNetworkInfo(0); if (localNetworkInfo2 != null && localNetworkInfo2.getState() == NetworkInfo.State.CONNECTED) { arrayOfString[0] = "1"; arrayOfString[1] = localNetworkInfo2.getSubtypeName(); return arrayOfString; } return arrayOfString; }
From source file:Main.java
public static Map<String, String> getNetworkInfo(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); Map<String, String> map = new HashMap(); NetworkInfo info = cm.getActiveNetworkInfo(); if ((info == null) || (!info.isConnectedOrConnecting()) || (withinInBlackList())) { map.put("access_subtype", "offline"); map.put("access", "offline"); map.put("carrier", ""); } else {//from ww w. j a v a2s.c o m map.put("access_subtype", info.getSubtypeName()); map.put("access", cleanNetworkTypeName(info.getTypeName())); TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String carrierName = manager.getNetworkOperatorName(); map.put("carrier", carrierName); } return map; }
From source file:Main.java
public static int getCurrentNetType(Context context) { int result = NETTYPE_NONE; NetworkInfo localNetworkInfo = getCurrentActiveNetworkInfo(context); if (localNetworkInfo == null) { return result; }//from ww w . java2s . c om if (localNetworkInfo.getState() == NetworkInfo.State.CONNECTED) { if (localNetworkInfo.getType() == 1) { result = NETTYPE_WIFI; } else if (localNetworkInfo.getType() == 0) { String subTypeName = localNetworkInfo.getSubtypeName().toUpperCase(Locale.getDefault()); if (subTypeName.indexOf("GPRS") > 1) { result = NETTYPE_MOBILE_GPRS; } else if (subTypeName.indexOf("EDGE") > 1) { result = NETTYPE_MOBILE_EDGE; } else { result = NETTYPE_MOBILE_3G; } } else { result = NETTYPE_UNKNOW; } } else if (localNetworkInfo.getState() == NetworkInfo.State.CONNECTING) { result = NETTYPE_UNKNOW; System.out.println("connecting " + localNetworkInfo.getType()); } return result; }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
private static String getNetworkInfoInfo(NetworkInfo info) { String ret = ""; ret += info.getSubtypeName() + "/ "; if (info.getState() != null) ret += "s=" + info.getState().name() + "/ "; if (info.getDetailedState() != null) ret += "d=" + info.getDetailedState().name() + "/ "; if (info.getExtraInfo() != null) ret += "e=" + info.getExtraInfo(); return ret;//from w w w.ja va2 s. c o m }
From source file:com.sxnyodot.uefqvmio207964.Util.java
static String m959i(Context context) { if (context != null) { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")) .getActiveNetworkInfo(); if (!(activeNetworkInfo == null || !activeNetworkInfo.isConnected() || activeNetworkInfo.getTypeName().equals("WIFI"))) { return activeNetworkInfo.getSubtypeName(); }//w ww .j a v a 2s . co m } return ""; }
From source file:android_network.hetnet.vpn_service.Util.java
public static String getNetworkInfo(Context context) { StringBuilder sb = new StringBuilder(); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ani = cm.getActiveNetworkInfo(); List<NetworkInfo> listNI = new ArrayList<>(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) listNI.addAll(Arrays.asList(cm.getAllNetworkInfo())); else/* w ww. j a v a 2 s . com*/ for (Network network : cm.getAllNetworks()) { NetworkInfo ni = cm.getNetworkInfo(network); if (ni != null) listNI.add(ni); } for (NetworkInfo ni : listNI) { sb.append(ni.getTypeName()).append('/').append(ni.getSubtypeName()).append(' ') .append(ni.getDetailedState()) .append(TextUtils.isEmpty(ni.getExtraInfo()) ? "" : " " + ni.getExtraInfo()) .append(ni.getType() == ConnectivityManager.TYPE_MOBILE ? " " + Util.getNetworkGeneration(ni.getSubtype()) : "") .append(ni.isRoaming() ? " R" : "") .append(ani != null && ni.getType() == ani.getType() && ni.getSubtype() == ani.getSubtype() ? " *" : "") .append("\r\n"); } try { Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); if (nis != null) while (nis.hasMoreElements()) { NetworkInterface ni = nis.nextElement(); if (ni != null && !ni.isLoopback()) { List<InterfaceAddress> ias = ni.getInterfaceAddresses(); if (ias != null) for (InterfaceAddress ia : ias) sb.append(ni.getName()).append(' ').append(ia.getAddress().getHostAddress()) .append('/').append(ia.getNetworkPrefixLength()).append(' ') .append(ni.getMTU()).append(' ').append(ni.isUp() ? '^' : 'v') .append("\r\n"); } } } catch (Throwable ex) { sb.append(ex.toString()).append("\r\n"); } if (sb.length() > 2) sb.setLength(sb.length() - 2); return sb.toString(); }
From source file:com.master.metehan.filtereagle.Util.java
public static String getNetworkInfo(Context context) { StringBuilder sb = new StringBuilder(); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ani = cm.getActiveNetworkInfo(); List<NetworkInfo> listNI = new ArrayList<>(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) listNI.addAll(Arrays.asList(cm.getAllNetworkInfo())); else//from ww w . j a va 2 s.c o m for (Network network : cm.getAllNetworks()) { NetworkInfo ni = cm.getNetworkInfo(network); if (ni != null) listNI.add(ni); } for (NetworkInfo ni : listNI) { sb.append(ni.getTypeName()).append('/').append(ni.getSubtypeName()).append(' ') .append(ni.getDetailedState()) .append(TextUtils.isEmpty(ni.getExtraInfo()) ? "" : " " + ni.getExtraInfo()) .append(ni.getType() == ConnectivityManager.TYPE_MOBILE ? " " + Util.getNetworkGeneration(ni.getSubtype()) : "") .append(ni.isRoaming() ? " R" : "") .append(ani != null && ni.getType() == ani.getType() && ni.getSubtype() == ani.getSubtype() ? " *" : "") .append("\r\n"); } try { Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); if (nis != null) { sb.append("\r\n"); while (nis.hasMoreElements()) { NetworkInterface ni = nis.nextElement(); if (ni != null) { List<InterfaceAddress> ias = ni.getInterfaceAddresses(); if (ias != null) for (InterfaceAddress ia : ias) sb.append(ni.getName()).append(' ').append(ia.getAddress().getHostAddress()) .append('/').append(ia.getNetworkPrefixLength()).append(' ') .append(ni.getMTU()).append("\r\n"); } } } } catch (Throwable ex) { sb.append(ex.toString()).append("\r\n"); } if (sb.length() > 2) sb.setLength(sb.length() - 2); return sb.toString(); }
From source file:com.polyvi.xface.extension.XNetworkConnectionExt.java
/** * ./* ww w . java 2 s .c o m*/ * * @param info ?? * @return ? */ private String getType(NetworkInfo info) { if (null != info) { String type = info.getTypeName(); if (type.toLowerCase().equals(WIFI)) { return TYPE_WIFI; } else if (type.toLowerCase().equals(MOBILE)) { type = info.getSubtypeName(); if (type.toLowerCase().equals(GSM) || type.toLowerCase().equals(GPRS) || type.toLowerCase().equals(EDGE)) { return TYPE_2G; } else if (type.toLowerCase().startsWith(CDMA) || type.toLowerCase().equals(UMTS) || type.toLowerCase().equals(ONEXRTT) || type.toLowerCase().equals(EHRPD) || type.toLowerCase().equals(HSUPA) || type.toLowerCase().equals(HSDPA) || type.toLowerCase().equals(HSPA)) { return TYPE_3G; } else if (type.toLowerCase().equals(LTE) || type.toLowerCase().equals(UMB) || type.toLowerCase().equals(HSPA_PLUS)) { return TYPE_4G; } } } else { return TYPE_NONE; } return TYPE_UNKNOWN; }