Possible Duplicate:
How can I open android browser with specified POST parameters?
I would like to do something like this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.somepage.com?par1=val1&par2=val2"));
But I dont want to send the parameters with get but with post. How can I do this as described above?
Many thanks in advance, navajo
It can be done, but in a tricky way.
You can create a little html file with an auto submit form, read it into a string, replace params and embed it in the intent as a data uri instead of a url. There are a couple little negative things, it only works calling default browser directly, and trick will be stored in browser history, it will appear if you navigate back.
Here is an example:
HTML file (/res/raw):
Source code:
Navajo,
What you are trying to do cannot be done with the above URL with the constraints that you have made above. The primary reason for this is that the URL above IS a GET URL. A POST URL does not have the above parameters in it. They are passed in the actual REQUEST and not the URL.
To accomplish what you wish to do, you would have to intercept the Intent, reformat the URL and then start the browser with a new Intent. The source of the URL is the key. If the source is from you or something you can track, that is easy, just create a custom Intent. If the source is outside of your control, then you can run into problems (see below)...
1) GETs and POSTs are not interchangable. If you are messing with data that is not yours or is not going to a site that you control, then you may break the functionality of that site, because not everyone programs for both GETs and POSTs for security reasons.
2) If you are responding to the same Intent that the browser does, then it is possible that the User may not understand what your app does if it always opens the default.
Another possibility, (if you are in control of the website), is to respond to the Intent by creating a cookie that your site can read with the actual data requirements. This would require PHP/ASP on the server or JS activated HttpRequest().
If I had more information I could advise you better.
FuzzicalLogic