小弟现在做一个android手机客服端要去连接服务器其中url的网址到底是要什么网址啊????连接了服务器的网址但是没有数据返回,项目里边的网络连接授权弄了的。比如我要连接百度首页要把百度首页的所有东西都能返回回来在LOG中打印出来要怎么做呢? 求达人帮忙啊,还有JSP是不是就是网页的页面啊?这个对于android手机客服端是不是很重要啊???
------最佳解决方案--------------------
String result = "";
// String urlStr = "http://tv.ruyi.com/portal";
String urlStr = "http://XX.XX.XX.XX:XXXX/live/index.jsp";
Proxy proxy = new Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress("10.0.0.172",80));
URL url = new URL(urlStr);
HttpURLConnection conn=(HttpURLConnection) url.openConnection(proxy);
if (conn == null){
throw new IOException("URLConnection instance is null");
}
conn.setConnectTimeout(30000);//
conn.setDoOutput(true); // 发送POST请求必须设置允许输出,表示允许对外输出
conn.setUseCaches(false); // 不使用Cache
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "*/*");
conn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接
conn.setRequestProperty("Charset", "UTF-8");
conn.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
int responseCode = conn.getResponseCode();
Log.e("IndexActivity","responseCode is:"+responseCode);
if(responseCode == 200){
InputStream stream = conn.getInputStream();
result = inStream2String(stream);
String temvit = result;
Log.e("error","result" + result);
if (temvit.substring(0, 3).trim().equals("861")
------其他解决方案--------------------
请楼主百度Android WebView,应该有楼主想要的内容
------其他解决方案--------------------
你是发请求的,首先要确保你的请求得到了处理,是否请求成功
------其他解决方案--------------------