2

I've a webview that loads a local html file. The problem is simple. It cannot load something from any url, an image, a js file etc.

<html>
<head>
<script src="http://code.jquery.com/jquery-1.12.1.min.js" type="text/javascript"></script>
</head>
<body>
<img src="http://website.com/myimage.jpg" />
</body>

I added necessary permission tag into my manifest file.

<uses-permission android:name="android.permission.INTERNET" />

I'm not using cordova/phonegap. It just a webview that loads a local html file.

WebView webView=(WebView)findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccessFromFileURLs(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setAllowContentAccess(true);
        webView.getSettings().setAllowFileAccessFromFileURLs(true);
        webView.getSettings().setAllowUniversalAccessFromFileURLs(true);

I've been searching since the morning and nothing works. I promise I'm going to pray until end of my life for the one who solves this problem

1 Answer 1

1

Try this Put your file in assets folder and use

webView.loadurl("file:///android_asset/yourfilename.html");

Hope it helps thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.