AndroidWebView有时会显示net::ERR_CACHE_MISS消息
创始人
2024-10-12 03:30:57
0

在WebView的WebViewClient中覆盖shouldInterceptRequest方法,以在请求URL时设置正确的缓存模式。以下是示例代码:

@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    WebResourceRequest request = new WebResourceRequest(url, true);
    String reqUrl = request.getUrl().toString();
    boolean isForMainFrame = request.isForMainFrame();
    boolean isRedirect = request.isRedirect();
    boolean hasGesture = request.hasGesture();
    String method = request.getMethod();
 
    //设置WebView的缓存模式
    if (!TextUtils.isEmpty(reqUrl)) {
        CacheControl cacheControl = new CacheControl.Builder()
                .noCache()
                .build();
        Request newRequest = new Request.Builder()
                .cacheControl(cacheControl)
                .url(reqUrl)
                .build();
        return super.shouldInterceptRequest(view, newRequest);
    } else {
        return super.shouldInterceptRequest(view, url);
    }
}

相关内容

热门资讯

透视安卓版"wepo... 1、透视安卓版"wepokerplus万能挂"详细辅助透明教程(俱乐部辅助器透视)。2、wepoke...
透视黑科技"hhpo... 透视黑科技"hhpoker是内部控制吗"详细辅助解说技巧(透视脚本下载攻略);hhpoker是内部控...
透视黑科技"wepo... 透视黑科技"wepoker轻量版透视方法"详细辅助详细教程(透视脚本免费app攻略)准备好在wepo...
透视了解"aapok... 1、透视了解"aapoker俱乐部靠谱吗"详细辅助透明挂教程(辅助脚本攻略)2、进入游戏-大厅左侧-...
透视了解"hhpok... 透视了解"hhpoker透视方法"详细辅助揭秘攻略(可以挂底牌技巧)1、点击下载安装,微扑克wpk插...
透视app"约局吧开... 透视app"约局吧开挂神器是真的吗"详细辅助第三方教程(有透视方法技巧);最新版2024是一款经典耐...
透视了解"wepok... 透视了解"wepoker私人局俱乐部怎么进"详细辅助爆料教程(有挂神器);实战中需综合运用上述技巧,...
透视软件"wepok... 透视软件"wepoker私人局外卦"详细辅助AI教程(正确养号方法技巧)是一款可以让一直输的玩家,快...
透视脚本"we po... 透视脚本"we poker辅助器v3.3"详细辅助安装教程(辅助器激活码透视)准备好在we poke...
透视插件"德州透视脚... 透视插件"德州透视脚本"详细辅助存在挂教程(透视挂底牌攻略);科技安装教程;136704302。相信...