I have the following code (simplified for simplicity) which takes the user to the URL specified:
Button b = (Button) findViewById( R.id.button );
b.setOnClickListener( new OnClickListener() {
public void onClick( View v ) {
Intent i = new Intent( Intent.ACTION_VIEW );
i.setData( Uri.parse( "http://example.com/myform/?a=b&c=d&e=f" ) );
if (i.resolveActivity(getPackageManager()) != null) {
startActivity( i );
}
}
} );
which works well, but is a little ugly because the CGI parameters are shown in the URL bar of the Android web browser (they're various ugly session keys, etc). Is there a way to do the same using HTTP POST so they're hidden?
It's not possible in the browser, but it would be possible if you used a WebView
:
byte[] post = EncodingUtils.getBytes("a=b&c=d&e=f", "BASE64");
webview.postUrl("http://example.com/myform/", post);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With