android - Cordova plugin javascript not getting response data from Plugin -
i using cordova develop hybird app android. writing simple plugin alert "hello" message.
so have testplugin.java
public class testplugin extends cordovaplugin { @override public boolean execute(final string action, final jsonarray args, final callbackcontext callbackcontext) throws jsonexception { callbackcontext.sendpluginresult(new pluginresult(pluginresult.status.ok, "hello")); return true; } }
my config.xml:
<?xml version='1.0' encoding='utf-8'?> <widget id="com.essue.magicmirror" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>myproject</name> <description> sample apache cordova application responds deviceready event. </description> <author email="dev@cordova.apache.org" href="http://cordova.io"> apache cordova team </author> <content src="index.html" /> <access origin="*" /> <feature name="testplugin"> <param name="android-package" value="com.my.project.plugin.testplugin" /> </feature> </widget>
relevant part of index.html:
<script> $('.start-btn').click(function() { cordova.exec(new function(data){ alert(data); }, null, "testplugin", "say", []); }); </script>
when button $('.start-btn') clicked, alert pops "undefined", means not getting response text plugin.
am missing something? thanks
Comments
Post a Comment