how to save & restore Webview State?

后端 未结 4 1618
时光取名叫无心
时光取名叫无心 2020-12-16 06:08

when i use backup & restore Webview state ,i recive this message : the webpage at x Address might be temporarity down or may have moved permanently to a new web address.

4条回答
  •  被撕碎了的回忆
    2020-12-16 06:17

     if (isInternetPresent) {
            // Internet Connection is Present
            // make HTTP requests
            // showAlertDialog(HomeScreen.this, "Internet Connection",
            // "You have internet connection", true);
    
            webviewbrowse.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
            webviewAds.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
            webviewbrowse.loadUrl("http://www.example.com");
        } else {
            // Internet connection is not present
            // Ask user to connect to Internet
            webviewbrowse.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            webviewAds.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            webviewbrowse.loadUrl("http://example.com");
            showAlertDialog(HomeScreen.this, "internet doesn't connect",
                    " please connect to internet", false);
        }
    

提交回复
热议问题