public void connect(String httpUrl){
String host = null;
ConnectivityManager connectivityManager = (ConnectivityManager) activity
.getSystemService(activity.CONNECTIVITY_SERVICE);
NetworkInfo networkinfo = connectivityManager.getActiveNetworkInfo();
if(networkinfo.getExtraInfo().equals("cmwap")){
httpUrl = httpUrl.substring(7);
host = httpUrl.substring(0, httpUrl.indexOf("/"));
httpUrl = httpUrl.substring(httpUrl.indexOf("/"));
httpUrl = "http://10.0.0.172:80" + httpUrl;
}
URL url = new URL(httpUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if(networkinfo.getExtraInfo().equals("cmwap")){
conn.setRequestProperty("X-Online-Host", host);
}
}
String host = null;
ConnectivityManager connectivityManager = (ConnectivityManager) activity
.getSystemService(activity.CONNECTIVITY_SERVICE);
NetworkInfo networkinfo = connectivityManager.getActiveNetworkInfo();
if(networkinfo.getExtraInfo().equals("cmwap")){
httpUrl = httpUrl.substring(7);
host = httpUrl.substring(0, httpUrl.indexOf("/"));
httpUrl = httpUrl.substring(httpUrl.indexOf("/"));
httpUrl = "http://10.0.0.172:80" + httpUrl;
}
URL url = new URL(httpUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if(networkinfo.getExtraInfo().equals("cmwap")){
conn.setRequestProperty("X-Online-Host", host);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货