Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does android webview browsers support html5 features?

Tags:

I have HTML5 based web application i want it to integrate with WebView ,So does android webview browsers support html5 features?

like image 368
Devendra Shewale Avatar asked May 15 '12 11:05

Devendra Shewale


People also ask

What are the features provided by WebView?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.

What browser is used in WebView?

On Android 7.0, 8.0 and 9.0, Google Chrome handles the embedded browsing functions. On other Android OS versions, web app performance may suffer without WebView enabled.

What is Android WebView browser?

Android System WebView is a smaller version of Chrome that allows you to open links within the app you're using so that you won't have to leave the app. Image source: Google Play Store.

Is WebView an embedded browser?

Android System WebView is a system component that lets Android apps display web content inside them without opening a dedicated browser. In other words, Android System WebView is a web browser engine or an embedded web browser dedicated solely for apps to show web content.


1 Answers

A WebView supports them, but you have to turn them on. I use the following code which turns on every features which are available. This is necessary because Application Caches for example are not supported on All Android-Versions:

    wv = (WebView) findViewById(R.id.webview);
    WebSettings ws = wv.getSettings();

    ws.setJavaScriptEnabled(true);
    ws.setAllowFileAccess(true);


    if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.ECLAIR) {
        try {
            Log.d(TAG, "Enabling HTML5-Features");
            Method m1 = WebSettings.class.getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
            m1.invoke(ws, Boolean.TRUE);

            Method m2 = WebSettings.class.getMethod("setDatabaseEnabled", new Class[]{Boolean.TYPE});
            m2.invoke(ws, Boolean.TRUE);

            Method m3 = WebSettings.class.getMethod("setDatabasePath", new Class[]{String.class});
            m3.invoke(ws, "/data/data/" + getPackageName() + "/databases/");

            Method m4 = WebSettings.class.getMethod("setAppCacheMaxSize", new Class[]{Long.TYPE});
            m4.invoke(ws, 1024*1024*8);

            Method m5 = WebSettings.class.getMethod("setAppCachePath", new Class[]{String.class});
            m5.invoke(ws, "/data/data/" + getPackageName() + "/cache/");

            Method m6 = WebSettings.class.getMethod("setAppCacheEnabled", new Class[]{Boolean.TYPE});
            m6.invoke(ws, Boolean.TRUE);

            Log.d(TAG, "Enabled HTML5-Features");
        }
        catch (NoSuchMethodException e) {
            Log.e(TAG, "Reflection fail", e);
        }
        catch (InvocationTargetException e) {
            Log.e(TAG, "Reflection fail", e);
        }
        catch (IllegalAccessException e) {
            Log.e(TAG, "Reflection fail", e);
        }
    }
like image 167
theomega Avatar answered Oct 18 '22 15:10

theomega