在机器人的WebView PhoneGap的/科尔多瓦更改属性 [英] android phonegap/cordova change property on webview

查看:150
本文介绍了在机器人的WebView PhoneGap的/科尔多瓦更改属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去,我已经改变了正常的在Android网页视图属性。例如:

In the past, I have changed a normal Webview property on Android. For example:

wv.getSettings().setAllowUniversalAccessFromFileURLs(true);

在这里是西弗吉尼亚州的WebView的变量。现在,我有一个的PhoneGap /科尔多瓦应用程序,我想改变
在同一行code的,我一直在努力的方式如下:

where wv is a variable of webview. Now, I have an phonegap/cordova app, and I want to change the same line of code, I have been trying the the following way:

super.appView.getSettings()setAllowUniversalAccessFromFileURLs(真);

和也喜欢:

super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);

我没有得到任何编译错误,但是当我再补充一点行code对onCreate方法,应用程序只是关闭。我一直在尝试添加该行的onCreate方法在不同的地方,比如,前后super.onCreate后前加载HTML( super.loadUrl(文件后:/// android_asset /www/index.html),但应用程序始终关闭。任何人都知道,如果它是可以改变的PhoneGap的该属性/科尔多瓦?

I don't get any compiling errors, but when I add that line of code on the onCreate method, the app just closes. I have been trying to add the line on the onCreate method at different places, like, before and after the super.onCreate and before and after loading the html (super.loadUrl("file:///android_asset/www/index.html"), but the app always closes. Any of you know if it is possible to change that property on phonegap/cordova ?

推荐答案

这code已经在我们的网页视图,让您无需进行设置。也许这是崩溃的原因是,你是不是ICS的设备上运行。该方法仅在ICS或更好用。

That code is already in our web view so you don't need to set it. Probably the reason it is crashing is that you are not running on an ICS device. That method is only available in ICS or better.

如果你真的想添加它做的事:

If you really want to add it do:

if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
}

这篇关于在机器人的WebView PhoneGap的/科尔多瓦更改属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆