title: How to create a custom Plugin for Cordova2.3 - Android
body: <p>I am trying to create a custom plugin for Cordova - android. The purpose of the plugin is to raise an intent for a native android activity on click of a button on an HTML5 screen.
  So initially, I would be on an HTML5 screen with a button. On click of button, I should be redirected to a native android activity screen. </p>
  
  <p>Here is a bit of code I have already done,</p>
  
  <p>customplugin.js</p>
  
  <pre><code>function CustomPlugin(){};
  
  CustomPlugin.prototype.launchActivity = function(startClass) 
  {
  alert("@@@ Starting plugin to launch native activity.");
  cordova.exec(null, null, 'CustomPlugin', 'launchActivity', [startClass]);
  };
  
  if(!window.plugins) {
  window.plugins = {};
  }
  if (!window.plugins.customplugin) {
     window.plugins.customplugin = new CustomPlugin();
  }
  </code></pre>
  
  <p>In this code, however, I am getting 'Uncaught TypeError: cannot call method "launchActivity" of undefined.'
  Pls help me with some sample code examples. Thanks in advance.</p>
  
  <p>CustomPlugin.java</p>
  
  <pre><code>package org.apache.cordova.example;
  
  import org.apache.cordova.api.CallbackContext;
  import org.apache.cordova.api.CordovaPlugin;
  import org.apache.cordova.api.Plugin;
  import org.apache.cordova.api.PluginResult;
  import org.json.JSONArray;
  import org.json.JSONException;
  
  import android.util.Log;
  
  public class CustomPlugin extends CordovaPlugin 
  {
  @Override
      public boolean execute(String action, final JSONArray args, CallbackContext callbackContext) throws JSONException 
      {
          if ("launchActivity".equals(action)) 
          { 
                String goClass = null; if(args.length() &gt; 0) goClass = args.getString(0);
  
                Log.i("NATIVE", "Launch class : " + goClass); 
                return true;
            } 
            else 
            { 
                return false;
            }
      }
  </code></pre>