简体   繁体   中英

how to load angular 2 and html web page in android webview in offline mode?

I am trying below approach but it's taking around 10sec to load page even I cached the page.

**webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setAllowContentAccess(true);
        webSettings.setUseWideViewPort(true);
        webView.addJavascriptInterface(new 
        WebAppInterface(OfflineReportActivity.this), "android");
       webView.setWebViewClient(new Client());
        webView.setWebChromeClient(new ChromeClient());
       webView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ONLY);** 

you can load html file into your webview as url

 WebView lWebView = (WebView)findViewById(R.id.webView);

 File lFile = new File(Environment.getExternalStorageDirectory() + "<FOLDER_PATH_TO_FILE>/<FILE_NAME>");

 lWebView.loadUrl("file:///" + lFile.getAbsolutePath());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM