user1256477
user1256477

Reputation: 11201

opening a web from my android app, post values

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

Answers (2)

Kumar Vivek Mitra
Kumar Vivek Mitra

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

user1302884
user1302884

Reputation: 843

Android Webview POST

You can use a webview to open the webpage and then make a post request. Explained at the link given above.

Upvotes: 1

Related Questions