2

You know those clock widgets which allow you to open the Calendar by clicking on the date shown on the widget? How can they open the Calendar activity? How would you do if you had a common activity with a button and wanted to open the calendar by clicking on the button?

I searched around but the solutions I found does not work:

Intent i = new Intent();
ComponentName cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
i.setComponent(cn);
startActivity(s);

The above returns an exception, basically telling me that the activity I'm launching is not declared.

EDIT: I Want to open the default Calendar Activity, the grid with 01-nov, 02-nov, 03-nov etc. There is a way?

Can someone post an example?

felice.murolo
  • 146
  • 2
  • 9

2 Answers2

0
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);

shahab answered it for this question How to launch Android Calendar application using Intent (Froyo)

Community
  • 1
  • 1
Optimus
  • 2,716
  • 4
  • 29
  • 49
  • 2
    the code above opens an activity which allows me to create a Calendar Event. I Want to open the default Calendar Activity, the grid with 01-nov, 02-nov, 03-nov etc. There is a way? – felice.murolo Nov 01 '11 at 21:10
0

I've discovered that the android Emulator has not an Agenda or Calendar. So, I've tested the following simple code on a real device and it works:

Intent i = new Intent();
i.setClassName("com.android.calendar","com.android.calendar.AgendaActivity");
startActivity(i);

Now I have an agenda view in "list" format, but if I want to show the monthly format, I have to click on the monthly tab. I would show the monthly view directly. There is a way?

felice.murolo
  • 146
  • 2
  • 9