views:

54

answers:

1

I am developing part of an Android application that needs to use a WebView to open a password protected site. I am using SharedPreferences to provide the username and password from when the user logs in the app for the first time. I've tested the credentials it's returning, so I know that those are correct. When I run this in the emulator, the site says that I'm unauthorized (even though I am). Here's 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 wouldn't be authenticating me? Should the realm string that I put "" for actually be something?

A: 

if the site is using NTLM auth it won't work. Android does not natively support NTLM Auth. Fennec (firefox mobile) is the only android browser i've seen that supports it, but its still in alpha.

Ben
no, it's not using NTLM auth. still trying to figure this one out. thanks though.
oliverwhite