Skip to content Skip to sidebar Skip to footer

Optimal Webview Settings For Html5 Support?

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.setF

Solution 1:

I would add:

    mWebView.setWebViewClient(newWebViewClient()); // tells page not to open links in android browser and instead open them in this webview

Solution 2:

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/");

Solution 3:

You can also set like

try {
  WebSettingssettings= view.getSettings();
      settings.setJavaScriptCanOpenWindowsAutomatically(true);
      settings.setSupportMultipleWindows(true);
      settings.setBuiltInZoomControls(true);
      settings.setJavaScriptEnabled(true);
      settings.setAppCacheEnabled(true);
      settings.setAppCacheMaxSize(10 * 1024 * 1024);
      settings.setAppCachePath("");
      settings.setDatabaseEnabled(true);
      settings.setDomStorageEnabled(true);
      settings.setGeolocationEnabled(true);
      settings.setSaveFormData(false);
      settings.setSavePassword(false);
      settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
      // Flash settings
      settings.setPluginState(WebSettings.PluginState.ON);

      // Geo location settings
      settings.setGeolocationEnabled(true);
      settings.setGeolocationDatabasePath("/data/data/selendroid");
    } catch (Exception e) {
      SelendroidLogger.error("Error configuring web view", e);
    }

Solution 4:

IMHO, the answer probably has much more to do than your Android version than specific settings.

Take a look at the "Tables" section of CanIUse.com:

... or MobileHTML5.org:

Post a Comment for "Optimal Webview Settings For Html5 Support?"