I have done quite a bit of research and cannot find why this is not working. I have a Cordoba-based Android application in Eclipse running Cordova 2.7.0. I want to create a simple plugin that just warns the user about its completion.
My index.html
<head> <script type="text/javascript" src="cordova-2.7.0.js"></script> <script> window.func = function(str,callback){ alert("Outside Call Working"); cordova.exec(callback, function(err){alert(err)},"HelloPlugin","echo", [str]); } function callPlugin(str){ alert("JS Working"); window.func(str,function(){ alert("Done!"); }); } </script> </head> <body> <h2>PluginTest</h2> <a onclick="callPlugin('Plugin Working!')">Click me</a> </body>
My line is config.xml where I add the plugin
<plugin name="HelloPlugin" value="org.apache.cordova.plugin.HelloPlugin" />
And my actual HelloPlugin.java plugin, which is located in src / com / example / plugintest right next to MainActivity.java
package com.example.plugintest; import org.apache.cordova.api.CallbackContext; import org.apache.cordova.api.CordovaPlugin; import org.json.JSONArray; import org.json.JSONException; public class HelloPlugin extends CordovaPlugin{ @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { callbackContext.success(action); return true; } }
Any help is much appreciated!
source share