用户的联网方式大致有 wap net wifi 三种. 使用android包中提供的函数,HttpConnection只能使用net和wifi,wap方式无法访问. 问? 如何让程序可以通过wap访问网络?
解决方案 »
- 关于空气质量网站的接口
- jetty----- 在android手机里面搭建一个web服务器
- 关于LiswView CheckBox 全选问题
- 像瑞星卡卡助手那样的弹出动画怎样实现?
- service与activity交互总报错,请帮我看下。
- android发送短信的为什么不能运行
- monkeyrunner不能同时操作两个设备的疑问
- 如何编译源码生成的刷机包是bin格式的?
- APK文件如何发布
- android开发,binderService遇到的一个问题,求大神帮忙解决~
- 在哪里能获得比较多的android的软件或结识做android的软件的人呢?
- android在1.6api的条件下,如何实现多点触屏,高分请教。。。
conn.setRequestProperty("X-Online-Host", host);
}
conn.setRequestProperty("Accept", "text/plain");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Connection", "Close");
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
conn.connect();
private void doPost() throws IOException{
StringBuilder builder = new StringBuilder();
builder.append("http://");
if(bUsingProxy){
builder.append(proxy);
}else{
builder.append(host);
}
if(urlpage != null){
builder.append("/" + urlpage);
}
String desturl = builder.toString();
InputStream stream = null;
HttpURLConnection conn = null;
try{
byte[] data = params.getBytes();
URL url = new URL(desturl);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST"); conn.setConnectTimeout(connectTimeout);
conn.setReadTimeout(readTimeout);
conn.setDoOutput(true);
conn.setUseCaches(false);
if(bUsingProxy){
conn.setRequestProperty("X-Online-Host", host);
}
conn.setRequestProperty("Accept", "text/plain");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Connection", "Close");
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
conn.connect();
OutputStream outputStream = conn.getOutputStream();
outputStream.write(data);
outputStream.flush();
outputStream.close();
int resp_code = conn.getResponseCode();
Map<String, List<String>> headerMap = conn.getHeaderFields();
listener.action(NetworkListener.RESPONSE_CODE, new Integer(resp_code));
if(resp_code == HttpURLConnection.HTTP_OK){
stream = conn.getInputStream();
if(stream != null){
Log.d("cn.cmcc.t", "GETRESPONSE:" + resp_code);
}
if(mCommand != -1)
listener.action(NetworkListener.RECEIVE_STREAM, new Object[]{new Integer(mCommand),stream});
else
listener.action(NetworkListener.RECEIVE_STREAM, stream);
}
} catch (IOException e) {
e.printStackTrace();
listener.action(NetworkListener.REQUEST_TIMEOUT, null);
} finally{
if(stream != null)
stream.close();
if(conn != null)
conn.disconnect();
}
}
额? net方式, 不用做其他设置,就照普通的来,就可以上网的.... 我也很奇怪.
android.net.Proxy.getPort(context);获得端口