2

I want to open up the Calendar application from an android application. When i searched online, all i got this code.but it didn't work the below android 2.1. Is it possible to launch Calender application from an android application below 2.1? If possible, could someone please help me with it.

Calendar tempCal = (Calendar) mCalendar.clone();
    tempCal.set(year, month, day); 
    Intent calendarIntent = new Intent() ;
    calendarIntent.putExtra("beginTime", tempCal.getTimeInMillis());
    calendarIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    calendarIntent.setClassName("com.android.calendar","com.android.calendar.AgendaActivity");
    startActivity(calendarIntent);
Will Tate
  • 33,439
  • 9
  • 77
  • 71
kannappan
  • 2,250
  • 3
  • 25
  • 35
  • 1
    This is not valid approach to open standard Android activity using class name. You should use generic Intent. Check this for correct approach (not sure if that will work below 2.2): http://stackoverflow.com/questions/4373074/how-to-launch-android-calendar-application-using-intent-froyo – Zelimir Mar 28 '11 at 07:01

3 Answers3

4

I also recommend this: How to launch Android Calendar application using Intent (Froyo)

Community
  • 1
  • 1
Jaydeep Khamar
  • 5,975
  • 3
  • 32
  • 30
2
Intent intent = new Intent(Intent.ACTION_EDIT);  

intent.setType("vnd.android.cursor.item/event");

intent.putExtra("title", "Some title");

intent.putExtra("description", "Some description");

intent.putExtra("beginTime", eventStartInMillis);

intent.putExtra("endTime", eventEndInMillis);

startActivity(intent);
kannappan
  • 2,250
  • 3
  • 25
  • 35
0

To launch the activity for adding an event to the calendar, use:

    Intent intent = new Intent();

    intent.setType("vnd.android.cursor.item/event"); 
    intent.putExtra("beginTime", startTimeInMilliseconds); 
    intent.putExtra("endTime", endTimeInMilliseconds);

    intent.setAction(Intent.ACTION_EDIT);
    startActivity(intent);
Herb Meehan
  • 177
  • 1
  • 11
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281