gpt4 book ai didi

android - WebChromeClient 的基本身份验证

转载 作者:行者123 更新时间:2023-11-30 02:05:19 25 4
gpt4 key购买 nike

使用 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?

最佳答案

您需要同时使用两者:

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);

关于android - WebChromeClient 的基本身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30751712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com