简体   繁体   English

Cordova custom_plugin使用

[英]Cordova custom_plugin use

I am using Cordova 6.1.1 and I am trying to run a hybrid app on my android phone 我正在使用Cordova 6.1.1,并且正在尝试在Android手机上运行混合应用程序

CordovaPlugin.java 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); //////////返回execute(action,cordovaArgs,callbackContext);

Where is value of Return and where is the configuration for changing location? Return的值在哪里,更改位置的配置在哪里?

Thanks for your cooperation 谢谢你的合作

You can return true by default. 您可以默认返回true。

    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 您可以在两种方法中传递值将通过.js文件接收

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM