I'm currently looking for a way to launch the default browser application on Android and pass a session cookie to it.
My application communicates with an external API over which I have no control using HttpClient, then passes the user to the site for the final stages.
I am aware that this is probably possible using a WebView, However I very specifically need to open the external browser application rather than using an internal WebView.
I know that:
Intent.ACTION_VIEW
Can be used to open the browser, however I have not managed to find much information about actually passing any additional data through.
Any help is much appreciated.
I'm currently looking for a way to launch the default browser application on Android and pass a session cookie to it.
This is not possible, sorry.
Do you know url-rewrite? It will help you achieve your demand. A url-write may be like this: "http://localhost:8080/test/error.jsp;jsessionid=C4E6732EBB4C17F409AB41143735C096".
The "jsessionid" is the key for sessionid, and C4E6732EBB4C17F409AB41143735C096 is the value. The key to represent the sessionid attribute is different depends on what language is used in the web projects.
So, if you want to keep the session, you can launch the default like this:
Uri uri = Uri.parse("http://localhost:8080/test/error.jsp;jsessionid=C4E6732EBB4C17F409AB41143735C096");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
the sessionid you can get from the HttpClient, and just add it behind your url.
There are also some problems that need to pay attention. First, in the url, the separator is ";" not "?", because the sessionid is in http header, not the http body. Second, if the browser already has a session with the server, then the url-rewrite won't work because the browser will use the its own session, to solve this, you can use you app to get the browser's session and use this session in the HttpClient.
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