1

I'm trying to pass on a URL of the form:

http://foo.com?param1=somevalue

to the Android Browser, however, once this URL is sent to the browser in this form exactly,

the browser seems to append a forward slash to the URL itself as follows:

http://foo.com/?param1=somevalue

And surprisingly, the android browser is having trouble parsing this. I'm not sure why this breaks the URL.

The invoking code is this:

Intent sampleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(sampleURL));
startActivity(sampleIntent);

Is this a bug with the Android browser or do I need to do something differently here?

Grammaton
  • 25
  • 7

1 Answers1

0

If you closely read How can I open android browser with specified POST parameters? question and the comments, I think you might get an answer. Basically it says that you cannot add extra params to POST to start the browser using Intent, however GET allows that. There is also a solution by @Pete for doing what you wish, inside a WebView(if that what you might want to consider):

WebView webview = new WebView(this);
setContentView(webview);
byte[] post = EncodingUtils.getBytes("postvariable=value&nextvar=value2", "BASE64");
webview.postUrl("http://www.geenie.nl/AnHeli/mobile/ranking/demo/index.php", post)

Hope this helps in someway.

Update

Check out Opening URL on Android web browser causes Google search question. It talks about using URLEncoder.encode before passing in the URL. It might help.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124