The PluginResult class is your friend:
public PluginResult(Status status, JSONObject message) { this.status = status.ordinal(); this.message = (message != null) ? message.toString(): "null"; }
or
public PluginResult(Status status, String message) { this.status = status.ordinal(); this.message = JSONObject.quote(message); }
In your case, it takes either a json object or a string. So to return a json array you need
JSONObject json = new JSONObject(); json.put("foo", "bar"); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, json));
source share