当前位置: 代码迷 >> Android >> android webview 调用 goBack() 回来上一页 页面有时候自动刷新
  详细解决方案

android webview 调用 goBack() 回来上一页 页面有时候自动刷新

热度:91   发布时间:2016-05-01 10:19:18.0
android webview 调用 goBack() 返回上一页 页面有时候自动刷新
我的布局里有一个webview,现在调用goBack() 返回上一页有时候会自动刷新,有没有办法可以控制它goback时不刷新

------解决方案--------------------
可以看看WebSettings的setCacheMode (int mode)方法
------解决方案--------------------
页面有变化会导致,从代码上看:
    if (sameDocumentNavigation)
        loadSameDocumentItem(item);
    else
        loadDifferentDocumentItem(item, loadType);
而loadDifferentDocumentItem函数
        switch (loadType) {
            case FrameLoadTypeReload:
            case FrameLoadTypeReloadFromOrigin:
                request.setCachePolicy(ReloadIgnoringCacheData);
                break;
            case FrameLoadTypeBack:
            case FrameLoadTypeBackWMLDeckNotAccessible:
            case FrameLoadTypeForward:
            case FrameLoadTypeIndexedBackForward:
                // If the first load within a frame is a navigation within a back/forward list that was attached 
                // without any of the items being loaded then we should use the default caching policy (<rdar://problem/8131355>).
                if (m_stateMachine.committedFirstRealDocumentLoad() && !itemURL.protocolIs("https"))
                    
  相关解决方案