Miscellaneous with Plugin vs appView.addJavascriptInterface

I want to create native apps in android using phonegap cordova. I found 2 ways to make my html file linked to my java file. I can use appView.addjavascriptInterface or make my java file a plugin. I want now which way is best. What are the differences in using a plugin or appView.addJavascriptInterface?

+4
source share
1 answer

Using the Cordova plugin is the recommended approach to expose Java code to the JavaScript level of your application. Take a look at the Plugin Development Guide and Plugin Development on Android .

addJavascriptInterface is part of the Android WebView API and is used internally by Apache Cordova Code for Android . There is at least one bug with Android 2.3, and this method can be avoided with the Apache Cordova plugin system.

What are the differences in using a plugin or appView.addJavascriptInterface?

The difference is that the Cordova plugin is a higher-level abstraction that allows you to consistently output your own code from various platforms (Android, iOS, among others), to the WebView that runs your JavaScript code. While addJavascriptInterface is an Android-specific method that is part of the WebView API that uses the Apache Cordova Android code.

+1
source

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


All Articles