我想在android中以编程方式提交表单。我不希望用户与网络浏览器进行任何交互。用户将在EditField中提供输入,然后通过HTTPwebmethod通过http post方法提交输入。但我没有取得任何成功。请指教。我在java中使用过HTMLUnit,但它不适用于android。以编程方式在android中提交html表格
final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage("http://www.mail.example.com");
final HtmlForm form = page1.getHtmlElementById("loginform");
final HtmlSubmitInput button = form.getInputByName("btrn");
final HtmlTextInput textField1 = form.getElementById("user");
final HtmlPasswordInput textField2 = form.getElementById("password");textField1.setValueAttribute("user.name");
textField2.setValueAttribute("pass.word"); final HtmlPage page2 = button.click();
你在正确的轨道上。你尝试了什么代码,以及你收到了什么错误信息?你是否也在托管接收端?你可以使用fiddler工具或wireshark拦截模拟器的请求吗? – 2010-06-01 12:51:53
代码在原始问题中发布,但在编译时,HTTPUnit lib不会转换为dalvik代码。我认为它应该在服务器上执行。不在模拟器中。 – Maneesh 2010-06-01 13:11:06