I'm interested in determining what the optimal settings are for a WebView that is intended to show HTML5 content.
Currently I'm using :
mWebView.setFocusable(true);
mWebView.setFocusableInTouchMode(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
mWebView.getSettings().setAppCacheEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
With these settings, the WebView score 189 (w/ 1 bonus) on html5test.com. I am wondering if there are any settings that I should/could change to get further compatibility with HTML5. Of course, this list is an amalgamation of settings compiled over some months, so I'm also open to being told I'm doing something wrong. I do not have control over the html content to be displayed but am trying to support as broad a swath of HTML5 as possible.
Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
JavaScript is disabled in a WebView by default. You can enable it through the WebSettings attached to your WebView . You can retrieve WebSettings with getSettings() , then enable JavaScript with setJavaScriptEnabled() . WebView myWebView = (WebView) findViewById(R.
This interface was deprecated in API level 12. This interface is now obsolete.
I would add:
mWebView.setWebViewClient(new WebViewClient()); // tells page not to open links in android browser and instead open them in this webview
Here is an (older) project concerned with optimal HTML5 settings:
http://code.google.com/p/html5webview/source/browse/trunk/HTML5WebView/src/org/itri/html5webview/HTML5WebView.java
FYI, normally I also set the database storage path for HTML5:
mWebView.getSettings().setDatabaseEnabled(true);
mWebView.getSettings().setDatabasePath("/data/data/" + Actvity.getPackageName() + "/databases/");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With