SungHo Jung
SungHo Jung

Reputation: 1

Cordova custom_plugin use

I am using Cordova 6.1.1 and I am trying to run a hybrid app on my android phone

CordovaPlugin.java

/**
 * Executes the request.
 *
 * This method is called from the WebView thread. To do a non-trivial amount of work, use:
 *     cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 *     cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action          The action to execute.
 * @param args            The exec() arguments.
 * @param callbackContext The callback context used when calling back into JavaScript.
 * @return                Whether the action was valid.
 */
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    CordovaArgs cordovaArgs = new CordovaArgs(args);
    return execute(action, cordovaArgs, callbackContext);
}

///////// return execute(action, cordovaArgs, callbackContext);

Where is value of Return and where is the configuration for changing location?

Thanks for your cooperation

Upvotes: 0

Views: 122

Answers (1)

J.D.
J.D.

Reputation: 1411

You can return true by default.

    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    CordovaArgs cordovaArgs = new CordovaArgs(args);
    return true;
}

if you want some callback than use

CallbackContext.success();

or

CallbackContext.error("");

you can pass value in both method will receive by .js file

Upvotes: 1

Related Questions