1
当我想让我的WebView加载需要Cookie的图像时,我遇到了麻烦。WebView未使用Cookie来加载图像
我已经设置了我的饼干上的“CookieManager”
final android.webkit.CookieManager instance = android.webkit.CookieManager.getInstance();
instance.setAcceptCookie(true);
instance.setCookie(".example.fr", mCookies, new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(final Boolean value) {
loadWebView();
}
});
web视图,然后加载自定义HTML字符串,因为该应用程序正在生成正确的HTML。
private void loadWebView() {
// this string is an example of a generated HTML
String htmlContent =
"<!DOCTYPE html>" +
"<html><head>" +
"<link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\" media=\"screen, projection\"/></head>" +
"<body><img src=\"www.example.fr/img.jpg\"/></body></html>";
mWebView.loadDataWithBaseUrl("file:///android_asset/", htmlContent, "text/html", "UTF-8", null);
}
我想代理与查尔斯代理网络电话和我注意到,请求www.example.fr/img.jpg
没有饼干在头设置。但是,当我使用Chrome debbuging检查WebView时,我可以看到Cookies正确地位于资源选项卡下。
看起来它们不用于图像下载。
任何提示或建议,使WebView使用Cookies进行资源下载?
谢谢。