package org.apache.cordova.bluetooth;
import android.widget.Toast;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
public class HjkPlugin extends CordovaPlugin {
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
//localTost 为对外调用的方法名
if("localTost".equals(action)){
Toast.makeText(cordova.getActivity(),"cordova plugin test :" + args.getString(0),Toast.LENGTH_LONG).show();
//callbackContext用来调用回调函数,success为调用成功的回调
callbackContext.success("toast success");
return true;
}
//error为返回错误时的回调
callbackContext.error("toast error");
return false;
}
}
评论0
最新资源