WebView.setHttpAuthUsernamePassword()不工作? [英] WebView.setHttpAuthUsernamePassword() not working?
问题描述
我开发一个Android应用程序,需要使用的WebView打开一个受密码保护的网站的一部分。我使用的共享preferences提供从时,在应用程序首次在用户登录的用户名和密码。我测试过它返回的凭据,所以我知道,那些是正确的。当我在模拟器中运行此,该网站说,我未经授权(即使我)。这里的code:
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?
推荐答案
Android的声称现在支持NTLM。我不知道这是否是的WebView的一部分
或只是浏览器。
Android claims to support NTLM now. I don't know if that is part of the WebView
or just the browser.
HTTPS://$c$c.google。 COM / p /安卓/问题/细节?ID = 4962
这篇关于WebView.setHttpAuthUsernamePassword()不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!