I have HTML5 based web application i want it to integrate with WebView ,So does android webview browsers support html5 features?
            Asked
            
        
        
            Active
            
        
            Viewed 2.8k times
        
    21
            
            
        - 
                    See here: http://stackoverflow.com/questions/3930045/android-webkit-webview-and-html5 – Adam Honoré May 15 '12 at 11:27
 
4 Answers
54
            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);
        }
    }
        theomega
        
- 31,591
 - 21
 - 89
 - 127
 
- 
                    My AndroidStudio keeps telling me not to hardcode `/data`. How can I replace the two occurrences? – Bowi Apr 04 '17 at 08:33
 - 
                    1
 - 
                    1As of Android P, this will almost certainly not work if it did before - [see here](https://developer.android.com/preview/restrictions-non-sdk-interfaces) – Ed Holloway-George Jun 04 '18 at 22:11
 - 
                    1
 - 
                    1I was looking for the reason why my angular 9 was not starting as expected. You saved me! Thanks! – Brijesh Lakkad Oct 31 '20 at 16:11
 
12
            
            
        On your android browser open this link : http://html5test.com it will give you all the information that you need : Parsing rules , Canvas ,video,Audio,elements,forms,webapp...
        moujib
        
- 742
 - 2
 - 7
 - 26
 
- 
                    1thanks @moujib this is awesome that will help me in desktop browsers too – Devendra Shewale May 15 '12 at 12:00
 
2
            
            
        Thanks @theomega I used the following way to enable using light touches to make a selection and activate mouseovers.
try {
    WebSettings.class.getMethod("setLightTouchEnabled", new Class[]{Boolean.TYPE});
} catch (SecurityException e) {         
    e.printStackTrace();
} catch (NoSuchMethodException e) {         
    e.printStackTrace();
} 
        nhahtdh
        
- 55,989
 - 15
 - 126
 - 162
 
        Devendra Shewale
        
- 407
 - 1
 - 5
 - 14
 
1
            
            
        You didn't specify which features you're looking for exactly,
but Android (and iOS) use Webkit. So yes.
        Andy
        
- 29,707
 - 9
 - 41
 - 58
 
- 
                    actually i m looking drag and drop ,video,canvas features like that s – Devendra Shewale May 15 '12 at 11:31
 - 
                    Actually the default Android browser has some troubles with a support of the features of HTML5. Maybe this [presentation](http://www.slideshare.net/retomeier/html5-or-android-for-mobile-development) will helpful for you. – kapandron May 15 '12 at 11:47