Phonegap plugin cant call native function of android

smotrporn

New Member
I am new on phonegap and android. I created a plugin in phonegap and android to call native function using javascrip.My coode is as below.plugin/BannerLink.js\[code\]var BannerLink = { callNativeFunction: function (success, fail, resultType) { //alert(resultType); return Cordova.exec( success, fail, "org.apache.cordova.example.BannerLink", "nativeFunction", [resultType]); alert(resultType); }};\[/code\]My html view file\[code\]function bannerPressed(link){ alert(link.rel); //window.location.href=http://stackoverflow.com/questions/15572803/link.rel; //window.open(link.rel); BannerLink.callNativeFunction( nativePluginResultHandler,nativePluginErrorHandler,link.rel );}function nativePluginResultHandler (result) { alert("SUCCESS: \r\n"+result );}function nativePluginErrorHandler (error) { alert("ERROR: \r\n"+error );}\[/code\]My BannerLink.java file\[code\]package org.apache.cordova.example;import org.apache.cordova.api.Plugin;import org.apache.cordova.api.PluginResult;import org.json.JSONArray;import android.app.AlertDialog;import android.util.Log;@SuppressWarnings("deprecation")public class BannerLink extends Plugin { @Override public PluginResult execute(String action, JSONArray args, String callbackId) { // TODO Auto-generated method stub AlertDialog alertDialog=new AlertDialog.Builder(null).create(); alertDialog.setTitle("Reset..."); alertDialog.show(); Log.d("HelloPlugin", "Hello, this is a native function called from PhoneGap/Cordova!"); //only perform the action if it is the one that should be invoked return new PluginResult(PluginResult.Status.ERROR); }}\[/code\]My config.xml file\[code\]<plugin name="BannerLink" value="http://stackoverflow.com/questions/15572803/org.apache.cordova.example.BannerLink"/>\[/code\]I am using phonegap 2.0Please correct me where I have made mistake.
 
Back
Top