android webview 浏览器是否支持 html5 功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10599739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does android webview browsers support html5 features?
提问by Devendra Shewale
I have HTML5 based web application i want it to integrate with WebView ,So does android webview browsers support html5 features?
我有基于 HTML5 的 Web 应用程序,我希望它与 WebView 集成,那么 android webview 浏览器是否支持 html5 功能?
回答by theomega
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:
AWebView
支持它们,但您必须打开它们。我使用以下代码打开每个可用的功能。这是必要的,因为所有 Android 版本都不支持例如应用程序缓存:
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);
}
}
回答by moujib
On your android browser open this link : http://html5test.comit will give you all the information that you need : Parsing rules , Canvas ,video,Audio,elements,forms,webapp...
在您的 android 浏览器上打开此链接:http: //html5test.com它将为您提供所需的所有信息:解析规则、画布、视频、音频、元素、表单、webapp...
回答by Devendra Shewale
Thanks @theomega I used the following way to enable using light touches to make a selection and activate mouseovers.
谢谢@theomega 我使用以下方式启用轻触来进行选择并激活鼠标悬停。
try {
WebSettings.class.getMethod("setLightTouchEnabled", new Class[]{Boolean.TYPE});
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
回答by Andy
You didn't specify which features you're looking for exactly,
but Android (and iOS) use Webkit. So yes.
您没有具体说明您正在寻找哪些功能,
但 Android(和 iOS)使用 Webkit。所以是的。