Hi! Just one more discovery that in my opinion is probably a bug in the framework. When you call setHttpAuthUsernamePassword only the first call is stored. If you try override values for the same host and realm it will only return the first entered user. Even after restarts of the client.
I even had clearCache(true) and that did not help. So if you need to update a value you must first call. WebViewDatabase.getInstance(this).clearHttpAuthUsernamePassword(); In my example you could as well skip the entire setHttpAuth/ getHttpAuth and pass the correct value but if you split the logic then it matters. BR Stoffe On Oct 15, 2:33 pm, Stoffe <kristoffer.gronow...@gmail.com> wrote: > Hi Matt! > > @Override > public void onCreate(Bundle savedInstanceState) { > > WebView webkit = (WebView) findViewById(R.id.web_view); > webkit.setHttpAuthUsernamePassword(page.getHost(), realm, > username, password); > webkit.setWebViewClient( new WebViewClient() { > @Override > public void onReceivedHttpAuthRequest (WebView view, > HttpAuthHandler handler, String host,String realm){ > String[] up = view.getHttpAuthUsernamePassword(host, realm); > if( up != null && up.length == 2 ) { > handler.proceed(up[0], up[1]); > } > else{ > Log.d("WebAuth","Could not find user/pass for domain :"+ > host+" with realm = "+realm); > } > } > }); > webkit.loadUrl(page.toString()); > > BR Stoffe > > On Oct 13, 12:17 am, Croccy22 <matthew.bea...@gmail.com> wrote: > > > Hi all, > > > I have a WebView in my layout which I want to display a web page in. > > However the webpage requires Basic Authentication. > > > If I try to access this web page in the normal android browser, I get > > prompted for a username and password which then gets remembered and > > works for the site in future. > > > I want to do the same thing in my application, but when I load the > > page into the webview it just comes straigt up with the Unauthorised > > message without prompting. > > > I guess the prompting for Authentication is written in code in the > > android browser. Does anyone know how to inject a username and > > password into the WebView? > > > I have done a search arond and found the setHttpAuthUsernamePassword > > (String host, String realm, String username, String password) Method, > > But can't seem to get it to work and I can't find anyone else who has > > either? Not sure if I am giving it the correc parameters as I'm a > > little confused by what is means as the Realm? > > > I assumed that if the site was myhost.dyndns.org then the hostname > > would be myhost and the realm would be dyndns.org? This didn't seem to > > work. I also tried connecting by IP Address but that makes the Realm > > setting even more confusing? > > > Any ideas on how I can get this working? > > > Thanks, Matt. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---