1

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.

user1256477
  • 10,763
  • 7
  • 38
  • 62

2 Answers2

1

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);

}
user229044
  • 232,980
  • 40
  • 330
  • 338
Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75
1

Android Webview POST

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

Community
  • 1
  • 1
user1302884
  • 783
  • 1
  • 8
  • 16