Submit form with POST data in Android app

前端 未结 2 596
孤街浪徒
孤街浪徒 2021-02-03 15:54

I\'ve been searching the web for a way to do this for about a week now, and I just can\'t seem to figure it out.

I\'m trying to implement an app that my college can use

2条回答
  •  忘掉有多难
    2021-02-03 16:35

    What's wrong with them just using the built in browser? You can also submit a form using UrlEncodedFormEntity and HttpClient.

    HttpParams params = new DefaultHttpParams(); // setup whatever params you what
    HttpClient client = new DefaultHttpClient(params);
    HttpPost post = new HttpPost("someurl");
    post.setEntity(new UrlEncodedFormEntity()); // with list of key-value pairs
    client.execute(post, new ResponseHandler(){}); // implement ResponseHandler to handle response correctly.
    

    Okay and after you have the response in a string. The response since its a page is going to be in html. You need to use a WebView to show the html. WebView has a method loadData() that takes a string of html and displays it.

提交回复
热议问题