I am developing a part of an Android application that needs to use WebView to open a password protected site. I use SharedPreferences to specify a username and password when a user first logs in to the application. I tested the returned credentials, so I know that they are correct. When I run this in the emulator, the site says that I am unauthorized (although I am). Here is the code:
setContentView(R.layout.browser); WebView browser = (WebView) findViewById(R.id.browser); browser.getSettings().setJavaScriptEnabled(true); SharedPreferences credentials = getSharedPreferences("credentials", 0); browser.setHttpAuthUsernamePassword("example.com", "", credentials.getString("username", ""), credentials.getString("password", "")); browser.loadUrl("http://example.com");
So does anyone know why this will not test me? Should the line of the sphere that I put "" really be something?
source share