我认为标题是不言自明的。我找不到任何提到 WebViews 支持摘要身份验证的资源或引用。
一些注意事项:
我不是在谈论基本身份验证,其中授权 header 使用 Base64 编码发送。
我只是谈论嵌入到应用程序中的 WebView,而不是可以使用 apache http 客户端的简单 http 请求。
最佳答案
您可以在 WebView 中设置一个 WebViewClient 并在 WebViewClient 中重写以下方法,请参阅下面的代码..
private class ExWebChromeClient extends WebViewClient {
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
super.onReceivedHttpAuthRequest(view, handler, host, realm); //To change body of overridden methods use File | Settings | File Templates.
}
}
webView.setWebViewClient(new ExWebChromeClient());//set your Extended WebViewClient here
在这里您可以显示一个身份验证对话框..参见 showHttpAuthentication method from Android native Browser app这里,这里显示一个 http 身份验证对话框,并在 WebView 中正确处理
关于Android WebView - 它支持摘要身份验证吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15974618/