简体   繁体   中英

Android web view is not loading, from asset folder

Working normal webpages correctly but,iframes are not loading.

W/cr_AwContentsClient: Denied starting an intent without a user gesture, URI 
file:///android_asset/assets/main.html

showing this message.

I tried this view.getSettings().setDatabaseEnabled(true); view.getSettings().setDomStorageEnabled(true); view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); view.getSettings().setSupportMultipleWindows(true); view.getSettings().setDatabaseEnabled(true); view.getSettings().setDomStorageEnabled(true); view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); view.getSettings().setSupportMultipleWindows(true); Can you please tell me the solutions?

Try this:

webview.loadUrl("file:///android_asset/assets/main.html");

if the above doesn't work then try this:

try {
    AssetManager assetManager = this.getAssets();
    InputStream stream = assetManager.open("editor.html");
    BufferedReader r = new BufferedReader(new InputStreamReader(stream));
    StringBuilder total = new StringBuilder();
    String line;
    while ((line = r.readLine()) != null) {
        total.append(line).append("\n");
    }
    webView.loadDataWithBaseURL(null, total.toString(), "text/html", "UTF-8", null);
} catch (Exception ex) { 
ex.printStackTrace();
}

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