How to open Calendar on Button Click and get clickable Date.
Asked
Active
Viewed 8,184 times
2 Answers
4
check this out: http://www.developer.com/ws/article.php/3850276/Working-with-the-Android-Calendar.htm
EDIT:
To open calendar from button click event add this code to onClick method:
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);

evilone
- 22,410
- 7
- 80
- 107
-
Hi evilone Thx. How it is implement on Button Click..? – Niranj Patel Feb 24 '11 at 12:37
-
@evilone: This is an undocumented, unsupported, and unreliable solution. This application will not exist on all devices, and as you have seen, Google will change how it gets used. – CommonsWare Feb 24 '11 at 12:46
-
If i write the above code on button click then it is giving Force Close. – Paresh Mayani Feb 24 '11 at 12:48
-
@CommonsWare Hello sir, is this a feasible(Valid) solution? i am asking as i am also in search of Calendar-view solution. Thanx – Paresh Mayani Feb 24 '11 at 12:49
-
@evilone my current SDK is 2.1 , I am getting this exception: "android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.calendar/com.android.calendar.LaunchActivity}; have you declared this activity in your AndroidManifest.xml?" , – Paresh Mayani Feb 24 '11 at 12:52
-
the emulator doesn't have a calendar application so it would not be able to find the application – evilone Feb 24 '11 at 13:05
0
Try using the CalendarView widget, see docs here
This isn't a dialog, so you'd have to create a dialog, wrap it around a CalendarView and launch it yourself.

James Booker
- 108
- 1
- 6
-
Extend the android.app.AlertDialog in the same way DatePickerDialog does, to wrap the CalendarView widget, see the [documentation](http://developer.android.com/reference/android/app/AlertDialog.html) for AlertDialog for how to add a custom layout to the view – James Booker Feb 24 '11 at 12:43