Android Question Opening default browser with headers

mc73

Well-Known Member
Licensed User
Longtime User
Inside my app's webView, I successfully login to a https site, and I get its cookie and other extra headers.
However, the next step of the app, is that user enters his credit cards details, and I really don't want this to be done inside my app.
I prefer this to be done in the external default android browser.
So, my question is if and how I can open the desired uri adding the needed headers.

I found this code:

B4X:
  Intent browserIntent = new Intent(
               Intent.ACTION_VIEW, Uri.parse(url));
       Bundle bundle = new Bundle();
       bundle.putString("iv-user", username);
       browserIntent.putExtra(Browser.EXTRA_HEADERS, bundle);
       activity.startActivity(browserIntent);
       activity.finish();

Haven't test it, but in order to do so, I would prefer to not create a lib for generating the bundle needed.

Any ideas? Thank you.
 

mc73

Well-Known Member
Licensed User
Longtime User
B4X:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, url)
Dim bundle As JavaObject
bundle.InitializeNewInstance("android.os.Bundle", Null)
Bundle.RunMethod("putString", Array("iv-user", username))
in.PutExtra("com.android.browser.headers", Bundle)
StartActivity(in)
Thank you Erel. I've done it using inline Java but yours is better. However, and unfortunately, this thing didn't work, cause I couldn't really pass the whole cookie. Default browser denied this, so the whole code is actually about EXTRA headers, thus, I couldn't make it work :(
If anyone knows a workaround I would be most happy to know.
 
Upvote 0
Top