WebView – onReceivedHttpAuthRequest nunca se detiene

Llegué a un bucle muerto en la aplicación webview de Android, la aplicación se bloquea en la función onReceivedHttpAuthRequest.

mWeb.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { mProgressBar.setVisibility(View.GONE); } @Override public void onReceivedHttpAuthRequest(WebView view,HttpAuthHandler handler, String host, String realm) { if (isAdded()) handler.proceed(getResources().getString(R.string.username), getResources().getString(R.string.pass)); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); mWeb.loadUrl(mUrl); 

Actividad

 mWebView.LoadUrl(url); await Task.Delay(10000); if (!mWebView.IsShown | cliente.ErroReportado) { Toast t = Toast.MakeText(Android.App.Application.Context, "Erro ao acessar o servidor, verifique conexão, usuário e senha e tente novamente!", ToastLength.Long); t.SetGravity(GravityFlags.Center, 0, 0); t.Show(); OnCreate(null); } } 

En WebViewClient


class ViewClient : WebViewClient { MainActivity _activity; public int iTentativasLogin { get; private set; } public bool ErroReportado { get; private set; } public ViewClient(MainActivity activity) { _activity = activity; } public override void OnReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, string host, string realm) { Toast t ; if (Usuario.Length == 0 | Senha.Length == 0) { t = Toast.MakeText(Android.App.Application.Context, "Usuário ou senha não preenchidos", ToastLength.Long); t.SetGravity(GravityFlags.Center, 0, 0); t.Show(); handler.Cancel(); ErroReportado = true; } else { iTentativasLogin++; if (iTentativasLogin < 4) { handler.Proceed(Usuario, Senha); } else { t = Toast.MakeText(Android.App.Application.Context, "Usuário ou senha incorretos", ToastLength.Long); t.SetGravity(GravityFlags.Center, 0, 0); t.Show(); handler.Cancel(); ErroReportado = true; } } } }

  • Frameloader buscar extra UA String - UAProfURL
  • Cómo habilitar las cookies en android webview?
  • ¿Cómo abrir un nuevo navegador desde WebViewClient?
  • SysUtils: ApplicationContext es null en ApplicationStatus (WebView)
  • Webview shouldinterceptrequest ejemplo
  • Comprobar si Android WebView está consumiendo eventos táctiles
  • WebView - WebPage no disponible
  • Obtener el ancho de contenido de Android WebView con desplazamiento vertical después de cargar la página
  • Adición de cabeceras personalizadas a todas las solicitudes de la vista web de shouldInterceptRequest en Android
  • Webfonts de Google que no funcionan con Web View en Android 4.0 y 4.2.2
  • Error al inflacionar la clase android.webkit.WebView ocurre esporádicamente en la producción
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.