开发者

Android intent to POST URL?

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 );
                }
   开发者_JAVA技巧     }
    } );

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


In the end, I continued to use HTTP GET, but set a cookie then redirected the browser to a 'clean' URL without the session parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜