Android WebView don't show html document - android

I have a html document, I've already tested on the html editor online website (http://htmledit.squarefree.com), it worked fine. However, WebView on android don't show this document, it only show text plain. I have very little experience with html, can anyone help me?

Make sure that your AndroidManifest.xml file includes
<uses-permission android:name="android.permission.INTERNET"/>
just after the
<uses-sdk />
tag. Without this, your app won't be able to access the Internet and therefore webview won't load anything.
HTH

Try -
WebView myWebView = (WebView) findViewById(R.id.webview1);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
This will enable javascript

Related

YouTube thumbnail won't load in webview

We have a WebView based android app which loads webpage consisting <a> tags linking to YouTube video.
The web app works fine in a browsers like Chrome for Android and loads thumbnail from YouTube as expected but within WebView the <a> tag won't load the thumbnail of YouTube video.
How can we force the WebView to behave similar to Chrome browser
Have tried setting clients like below, which didn't help
webview.setWebViewClient(new WebViewClient());
webview.setWebChromeClient(new WebChromeClient());
Even added hardware acceleration in AndroidManifest.xml but it didn't work either
android:hardwareAccelerated="true"
Note: JavaScript is also enabled.
Did you try to enable javascript in your webview?
You can enable it like this:
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

Android WebView won't load local files

I'm having a problem with Android WebView for my websites. When I open my site on any browser, the CSS style sheet, JavaScript and Images load. But when I open for example through Instagram (which uses WebView), I just have the html, naked.
I precise that all my links are in relative (I have a tag which indicates from where to look for the files).
Here, my base is <base href="http://anthony-e-b.rf.gd/" target="_top">
and my CSS, my images, and my JS refer to this as:
<link rel="stylesheet" href="assets/main.css"> (for the CSS).
Same for my pictures : href="assets/pics/mon_image.jpg".
I do not understand, and although I search the Internet I do not see any solution ...
thank you in advance for your help
Try:
WebView myWebView = findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
Hope it will help!

Stripe.js credit card input form invisible in Webview

I was trying to test if it is possible to integrate stripe js in a website and load that site in an android Webview to proceed for payment. I was using this link https://github.com/stripe/elements-examples to load that in Webview like this:
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("https://stripe.github.io/elements-examples/");
Everything is loading in the Webview except the credit card field is not there. Either it is not visible or it can not be editable. Why is that?
Try to add below code to enable Javascript in your Webview:
WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);

Webview Android does'nt load whole content from a large html file

I have a very large html file(around 10k lines of only text). When I use Webview to load this html content, it shows only around few hundreds and remaining space is blank(white space). Can someone help me with this issue? Thank You.
Following is my code:
WebView mWebView;
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/test.html");//test.html in assets folder
I also try with webView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null) or webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null) but it does'nt help.
I just found solution for my issue with Webview. The reason Webview can't display whole content of html file because the html is not well constructed, some html tag like <abc#.com> will not be read by Webview. So I convert content to correct html form then it works.

Android WebView does not display web page

As stated in this post Android WebView does not display web page correctly I have tried javascript enable, but still not working. Have any idea, where i am wrong?
WebView wv = (WebView) findViewById(R.id.webview1);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
wv.loadUrl("http://www.google.com");
Add:
<uses-permission
android:name="android.permission.INTERNET"></uses-permission>
to your AndroidManifest.xml if you haven't done so.
Also check if you have internet connection on your emulator. Try opening the Browser. If you do not have internet connection try to restart the emulator.

Categories

Resources