0

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

wv.getSettings().setAllowUniversalAccessFromFileURLs(true);

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(true);

and also like:

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

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 ?

Vinay
  • 6,891
  • 4
  • 32
  • 50
user1608382
  • 13
  • 1
  • 5

1 Answers1

2

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);
}
Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
  • a correction in your answer - the method is available only in Jelly Bean (ver. 16) onwards. Incidentally, the code you have given is correct since it uses '>' and not '>=' for ICS_MR1 – Rajath Jan 07 '13 at 08:03