If you just want to open a calendar that you can use and intend to use EITHER from these component names (you may need to service both if you want to support older phones)
Intent i = new Intent(); //Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...) cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity"); //less than Froyo cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity"); i.setComponent(cn); startActivity(i);
If you want to go to the event adding screen (which is better suited for your purpose), use something like:
//all version of android Intent i = new Intent(); // mimeType will popup the chooser any for any implementing application (eg the built in calendar or applications such as "Business calendar" i.setType("vnd.android.cursor.item/event"); // the time the event should start in millis. This example uses now as the start time and ends in 1 hour i.putExtra("beginTime", new Date().getTime()); i.putExtra("endTime", new Date().getTime() + DateUtils.HOUR_IN_MILLIS); // the action i.setAction(Intent.ACTION_EDIT); startActivity(i);
(code not verified, copied from an existing project)
source share