title: PhoneGap/Cordova calendar integration (Android)
body: <p>I'm building an Android app using PhoneGap (aka Cordova), and am having trouble getting a calendar integration to work.  <strong>Disclaimer:</strong> I'm a noob to both Android and PhoneGap, please bear with me.</p>
  
  <p>All I'm trying to do is add an event to the user's calendar.  Following <a href="http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-android.html" rel="nofollow">this tutorial</a>, I've created a Plugin that attempts to launch a Calendar Intent.  The code looks like this:</p>
  
  <pre><code>public class CalendarPlugin extends Plugin {
  public static final String NATIVE_ACTION_STRING="addToCalendar"; 
  public static final String SUCCESS_PARAMETER="success"; 
  
  @Override
  public PluginResult execute(String action, JSONArray data, String callbackId) {
      if (NATIVE_ACTION_STRING.equals(action)) { 
          Calendar beginTime = Calendar.getInstance();
          beginTime.set(2012, 6, 19, 7, 30);
          Calendar endTime = Calendar.getInstance();
          endTime.set(2012, 6, 19, 8, 30);
  
          Intent calIntent = new Intent((Context) this.ctx, CalendarPlugin.class)
              .setAction(Intent.ACTION_INSERT)
              .putExtra(Events.TITLE, "A new event")
              .putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true)
              .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
              .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());
  
          this.ctx.startActivity(calIntent);
          return new PluginResult(PluginResult.Status.OK, "Smashing success");
      }
  
  return new PluginResult(PluginResult.Status.ERROR, "Didn't work bro");
  }
  }
  </code></pre>
  
  <p>The Javascript code to invoke this plugin is standard:</p>
  
  <pre><code>var CalendarPlugin = { 
      callNativeFunction: function (success, fail, resultType) { 
          if (cordova) {
              return cordova.exec( success, fail, 
                  "org.myorg.appname.CalendarPlugin", 
                  "addToCalendar", [resultType]);
          }
          else {
              alert("Calendar function is not available here.");
          }
      } 
  };
  </code></pre>
  
  <p>The Android code is getting invoked (confirmed using a breakpoint).  But the result sent back to the Javascript code is an error: </p>
  
  <blockquote>
    <p>Unable to find explicit activity class {org.myorg.appname/org.myorg.appname.CalendarPlugin}; have you declared this activity in your AndroidManifest.xml?</p>
  </blockquote>
  
  <p>There's no mention of adding to AndroidManifest.xml in the tutorial, which leads me to believe I'm missing something (also, the <em>CalendarPlugin</em> code is being invoked successfully, so how could there be an error saying the <em>CalendarPlugin</em> class could not be found?).  If indeed I need to add <em>CalendarPlugin</em> to the manifest, how would I go about doing that?</p>