使用WebViewClient,我为BasicAuthentication使用了以下代码:
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("test_user", "test_password");
}
//If you will not use this method url links are opeen in new brower not in webview
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});现在,我将WebChromeClient用作:
webView.loadUrl(url);
webView.setWebChromeClient(new WebChromeClient() {
});在这种情况下,我该如何做BasicAuthentication?
发布于 2015-06-10 09:21:01
您需要同时使用两种方法:
webView.setWebChromeClient(new MyWebChromeClient());
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("test_user", "test_password");
}
//If you will not use this method url links are opeen in new brower not in webview
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl(url);https://stackoverflow.com/questions/30751712
复制相似问题