Android phonegap / cordova change property to webview

In the past, I changed the usual Webview property to Android. For instance:

 wv.getSettings().setAllowUniversalAccessFromFileURLs(true); 

where wv is the webview variable. Now I have a phonegap/cordova , and I want to change in the same line of code, I'm trying to do the following:

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

and:

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

I don't get compilation of errors, but when I add this line of code to the onCreate method, the application just closes. I try to add a line to the onCreate method in different places, for example, before and after super.onCreate and before and after loading html ( super.loadUrl("file:///android_asset/www/index.html") , but the application always closes Does any of you know if you can change this property to telephone / cordova?

0
source share
1 answer

This code is already in our web view, so you do not need to install it. Probably the reason this is happening is because you are not working on an ICS device. This method is available only in ICS or higher.

If you really want to add it:

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

Source: https://habr.com/ru/post/948812/


All Articles