2

I have to send some parameters to a url and open it, But i dont know how to do it

var variables:URLVariables = new URLVariables();
variables.param1 = "param1";
variables.param2 = "param2";

var request:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");                 
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request,"_blank");

This is an example in IOS but i dont know how to do it in android

i Think i have to do it with an intent but

params = URLEncoder.encode(""+ "cmd=param1"+ "&business=param2"+"utf-8");

String url = "https://www.paypal.com/cgi-bin/webscr" + params;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

startActivity(browserIntent);

i think i should do it like this but it is not working i am sending it to paypal

4
  • try using HttpClient with name value pairs Jun 30, 2014 at 5:24
  • but i have to open it in the android browser, how i do that Jun 30, 2014 at 5:27
  • You are totally wrong in your java approach Jun 30, 2014 at 5:27
  • I know IOS is different but, the IOS is usign a Post Method, the thing is, how do i add params to the url and open it, is there some method equivalent or a way ? Do i have to use a type of Post method ? Jun 30, 2014 at 5:33

1 Answer 1

4

this is what i was looking for

        String uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr")
                    .buildUpon()
                    .appendQueryParameter("param1", "param1")
                    .appendQueryParameter("param2", "parma2")
                    .build().toString();
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
            startActivity(browserIntent);
1
  • 1
    Awesome!! you save my life!
    – John Jang
    Jul 4, 2018 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.