Reputation: 11201
I need to go to a website from my android mobile, this website accept some POST values.
When I do the same from my computer, is a form with php:
<form name="form1" method="post" action="scripts/pago.php">
I can open a website with this code:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
It opens the browser without problem, but, how can I add the post values?
Thank you in advance.
Upvotes: 1
Views: 1980
Reputation: 33534
Try this out:
public void postData() throws Exception {
HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.xyz.com");
List<NameValuePair> list = new ArrayList<NameValuePair>(1);
list.add(new BasicNameValuePair("name","ABC");
httppost.setEntity(new UrlEncodedFormEntity(list));
HttpResponse r = client.execute(httppost);
}
Upvotes: 1
Reputation: 843
You can use a webview to open the webpage and then make a post request. Explained at the link given above.
Upvotes: 1