How To Return A Array Or Other Collections Elements Type From Phonegap Android Plugin
here is a part of my testing code in a java plugin (i'm using phonegap 2.7). public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONExcep
Solution 1:
PluginResult class is your friend:
public PluginResult(Status status, JSONObject message) {
this.status = status.ordinal();
this.message = (message != null) ? message.toString(): "null";
}
or
publicPluginResult(Status status, String message) {
this.status = status.ordinal();
this.message = JSONObject.quote(message);
}
In your case it accepts either a json object or a string. So to return a json array you need
JSONObject json = newJSONObject();
json.put("foo", "bar");
callbackContext.sendPluginResult(newPluginResult(PluginResult.Status.OK, json));
Post a Comment for "How To Return A Array Or Other Collections Elements Type From Phonegap Android Plugin"