Android WebView con WebViewClient: autenticación con onReceivedHttpAuthRequest

In my application, I use WebView with WebViewClient, with overriden method onReceivedHttpAuthRequest, where I prompt user to enter his credentials, using AlertDialog. When credentials are entered, I call

handler.proceed(username, password);

Mi problema es: In Android 4 emulator, everything works fine, user can navigate through authenticated sites without any problem, but in older Android versions, it seems that onReceivedHttpAuthRequest is called each time when user refreshes, or navigates to another page within authenticated site.

Can someone please suggest me, what am I doing wrong? Thank you.

Lo que probé:

Calling also

webView.setHttpAuthUsernamePassword(host, realm, username, password);

when credentials are entered and adding this piece of code before invoking login dialog in onReceivedHttpAuthRequest:

String[] usernamePassword = webView.getHttpAuthUsernamePassword(host, realm);
if (usernamePassword!=null) {
    handler.proceed(usernamePassword[0], usernamePassword[1]);
    return;
}

did not work for me - user can navigate through authenticated sites, but after logout, username and password are still stored in webView and user is logged-in automatically again - in this case I need to detect user's logout and remove stored credentials, can somebody tell me, how to do this?

Muchas gracias!

preguntado el 28 de agosto de 12 a las 11:08

I also encounter this issue -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.