During Android network development, you need to determine whether the current network connection mode is wifi or wap. If it is wap, you need to use proxy for access.
Why is proxy access required?
WAP is only a GPRS application mode, and it has nothing to do with the GRPS access mode. WAP applications adopt the "terminal + WAP Gateway + WAP Server" mode, which is different from the general "terminal + server" mode of Internet. The main purpose is to achieve WAP-WEB protocol conversion through WAP gateway to save network traffic and compatible with existing WEB applications.
private boolean isNeedProxy(final Context context) { boolean ret = false; final ConnectivityManager connectManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetInfo = connectManager.getActiveNetworkInfo(); if (activeNetInfo != null) { final String type = activeNetInfo.getTypeName(); // WIFI not available if (type.equalsIgnoreCase("WIFI")) { ret = false; } //Mobile else if (type.equalsIgnoreCase("MOBILE")) { final String mobileProxyIp = android.net.Proxy.getHost(context); final int mobileProxyPort = android.net.Proxy.getPort(context); if (mobileProxyIp == null || "".equals(mobileProxyIp) || mobileProxyPort == 0) { ret = false; } else { hostUrl = mobileProxyIp; hostPort = mobileProxyPort; ret = true; } } } return ret; }