Last active
July 5, 2018 08:17
-
-
Save molcik/456a4363354653ff144172a1c70c10a5 to your computer and use it in GitHub Desktop.
Cordova Example Android Plugin
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 com.filipmolcik.plugin; // This must match with the plugin.xml and package.json | |
import org.apache.cordova.CallbackContext; | |
import org.apache.cordova.CordovaPlugin; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
// Example is the 3rd parameter in javascript part | |
public class Example extends CordovaPlugin { | |
@Override // action is the 4th parameter, args is the array from 5th parameter in javascript part | |
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { | |
if (action.equals("YOUR_ACTION_NAME_PARAMETER")) { | |
// Your black magic comes here | |
return true; | |
} | |
return false; // Returning false results in a "MethodNotFound" error. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment