1、如:我的http://www.haha.com/submit.htm
<form action="http://www.haha.com/submit.php" method="post" onsubmit="submitTest();>
<INPUT name=username value="mytestname">
<INPUT name=content value="submit some">
<input type="button" name="submit">
</form>
怎么使用android模拟提交这个内容?2、能使用socket来做吗?httpsocket
<form action="http://www.haha.com/submit.php" method="post" onsubmit="submitTest();>
<INPUT name=username value="mytestname">
<INPUT name=content value="submit some">
<input type="button" name="submit">
</form>
怎么使用android模拟提交这个内容?2、能使用socket来做吗?httpsocket
解决方案 »
- 手机定位为null
- 快速心率检测软件Instant Heart Rate by Azumio 的工作原理
- Android SDK 在 PC机上 运行adb shell 不成功(环境变量已经配好了)
- 控件的背景色改变
- 学习LIstView与Adapter时的问题
- 求教TextView设置ellipsize为end,如何获取字符串截断的位置?
- TAG名字,用this.getClass().getSimpleName()归一化取得,有弊端吗?
- 【求助】安卓的应用有ios那样的软件名称抢注问题吗?
- 求思路,搜索方面的
- 谁有Android SDK Build Tools revision 19.1.0?
- root 权限问题 求大神
- 新人求助两个个问题 关于android开发。。。。求高手指点下
String baseUrl = http://www.haha.com/submit.htm;
String nam = name.getText().toString();
String ag = age.getText().toString();
NameValuePair nameValuePair1 = new BasicNameValuePair("name", nam);
NameValuePair nameValuePair2 = new BasicNameValuePair("age", ag);
List<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(nameValuePair1);
list.add(nameValuePair2);
try {
HttpEntity requestHttpEntity = new UrlEncodedFormEntity(list);
HttpPost httpPost = new HttpPost(baseUrl);
httpPost.setEntity(requestHttpEntity);
HttpClient httpClient = new DefaultHttpClient();
httpResponse=httpClient.execute(httpPost);
entity = httpResponse.getEntity();
inputstream = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream));
String result = null;
String line = null;
while((line=reader.readLine())!=null ){
result = result + line;
}
System.out.println("result------"+result);
System.out.println("response-------"+httpResponse);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
2,socket逻辑上也可以做,但你需要自己实现HTTP协议(主要是一些必要的头),发往80端口,并自己处理返回,解析HTTP协议,取出返回页面的内容。何必呢?
谢谢!