Ad

How To Fix An Android Application Not Loading Iframes?

- 1 answer

I'm building an android application with basic html/css/js and trying to compile it with Android Studio but somehow it compiles succesfully and turn it into an apk file and run but app won't load iframes.

I've searched over the internet and applied these steps given in here and other suggestions on other forums.

Other scripts in HTML, JS files and CSS animations work properly so I expect it to load iframes too (like cordova does) but doing

webView= (WebView) findViewById(R.id.webview); 
webView.setWebChromeClient(new WebChromeClient()); 
webView.setWebViewClient(new WebViewClient()); 
webView.getSettings().setJavaScriptEnabled(true);

won't work.

Ad

Answer

You can create String with HTML

String html = "<iframe width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"http://api.thingspeak.com/channels/31592/charts/1?width=450&height=260&results=60&dynamic=true\" ></iframe>";

after that call the method loadData():

webview.loadData(html, "text/html", null);
Ad
source: stackoverflow.com
Ad