Sandeep P
Sandeep P

Reputation: 4411

Plugin class is deprecated in Phonegap

i had observed the Plugin class in Phonegap is deprecated , So what is the replacement of plugin now, how can i communicate between java and JavaScript with out using JavaScript Interface class and plugin class

thanking you

Upvotes: 2

Views: 1975

Answers (1)

Manish Kumar
Manish Kumar

Reputation: 1062

The plugins have changed a bit in the recent release, instead of extending the PluginClass it now extends CordovaPlugin. You can find how to create plugins in the official docs.

Link to the android plugin development guide

public class Echo extends CordovaPlugin {
    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("echo")) {
            String message = args.getString(0); 
            this.echo(message, callbackContext);
            return true;
        }
        return false;
    }

    private void echo(String message, CallbackContext callbackContext) {
        if (message != null && message.length() > 0) { 
            callbackContext.success(message);
        } else {
            callbackContext.error("Expected one non-empty string argument.");
        }
    }
}

Upvotes: 2

Related Questions