Created
April 7, 2013 23:02
-
-
Save jrbistuer/5332976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.cordova.plugin; | |
import org.apache.cordova.api.CordovaPlugin; | |
import org.apache.cordova.api.PluginResult; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
public class Echo extends CordovaPlugin { | |
@Override | |
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { | |
if (action.equals("echo")) { | |
String message = args.getString(0); | |
this.echo(message, callbackContext); | |
return true; | |
} | |
return false; | |
} | |
private void echo(String message, CallbackContext callbackContext) { | |
if (message != null && message.length() > 0) { | |
callbackContext.success(message); | |
} else { | |
callbackContext.error("Expected one non-empty string argument."); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment