title: Android WebView with WebViewClient - authentication with onReceivedHttpAuthRequest
body: <p>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 </p>
  
  <pre><code>handler.proceed(username, password);
  </code></pre>
  
  <p><strong>My problem is:</strong>
  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.</p>
  
  <p>Can someone please suggest me, what am I doing wrong? Thank you.</p>
  
  <p><strong>What I tried:</strong></p>
  
  <p>Calling also</p>
  
  <pre><code>webView.setHttpAuthUsernamePassword(host, realm, username, password);
  </code></pre>
  
  <p>when credentials are entered and adding this piece of code before invoking login dialog in onReceivedHttpAuthRequest:</p>
  
  <pre><code>String[] usernamePassword = webView.getHttpAuthUsernamePassword(host, realm);
  if (usernamePassword!=null) {
      handler.proceed(usernamePassword[0], usernamePassword[1]);
      return;
  }
  </code></pre>
  
  <p>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 - <strong>in this case I need to detect user's logout and remove stored credentials</strong>, can somebody tell me, how to do this?</p>
  
  <p><strong>Many thanks!</strong></p>