Android doesnt notice when i do an WWW-Authenticat

2019-08-10 14:06发布

问题:

So my problem is the following:

I try do login to a website , which uses Basic Authentication (example picture:)

http://i.stack.imgur.com/z1DPt.png

The Authentication itself works, and i recieve the expected output as String via HTTPGet. But when i try to visit the site afterwards, using an intent like:

Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("Some Website"));
            handler.startActivity(browserIntent);

I get the window above shown again, which means, my phone doesnt know it has already been logged in.

So now is my question: How to save the information, that i have been logged in to the website? All i need to do is, to sumbit the Authorization Header so, that the Browser can recognize it.

回答1:

You need to use and save session cookies in your application .This can be achieved by saving your authentication cookies in shared preferences.For implementation look into cookie manager class in the developer page