How to create simple calendar on android

I need simple calendar for my android application, in which I can pick a date from it, and read data from database based on picked date. I'm having trouble finding good and simple example of calendar. Does anybody have a source code of simple calendar? Thanks!

Answers


Checkout these links with source code example, you'll get an idea about it:

Android-Calendar-Widget

Android-Calendar-GridView-Adapter

android-calendar-provider-tests


The Calendar API is available as of Android 4.0.

Creating new events is done via Intents and does not require any permission. Setting properties of the event is done via Intent extras. The user will be prompted if the event should be created.

For example the following will prompt the user if an event should be created with certain details.

 Intent intent = new Intent(Intent.ACTION_INSERT);
 intent.setData(CalendarContract.Events.CONTENT_URI);
 startActivity(intent);

You can also add dates and time, if this event is repeated and the like. See the comments in the coding for examples.

 Intent intent = new Intent(Intent.ACTION_INSERT);
 intent.setType("vnd.android.cursor.item/event");
 intent.putExtra(Events.TITLE, "Learn Android");
 intent.putExtra(Events.EVENT_LOCATION, "Home suit home");
 intent.putExtra(Events.DESCRIPTION, "Download Examples");

 // Setting dates
 GregorianCalendar calDate = new GregorianCalendar(2012, 10, 02);
 intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis());
 intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calDate.getTimeInMillis());

 // Make it a full day event
 intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

// Make it a recurring Event
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");

// Making it private and shown as busy
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

More about this article

and more calendar api tutorials


You should use a DatePicker... Because that's the only simple way through which users can pick a date and read data from a database based on that date... But hey you should also show your effort...


Here is a sample calendar app you can go through. http://droidwalk.blogspot.in/2012/11/android-calendar-sample.html#more


Need Your Help

python does not work

python windows installation windows-xp

I always downloaded python from python.org and install it on Windows machines (XP and 8 ) easily. On this Windows XP machine however I have the following problem. After installing python2.7 32 bi...

making the output appear faster on the client browser

php asp-classic buffer flush output-buffering

When I process large records in a while loop and each iteration of the loop outputs some info for the screen, I always find myself looking at an old screen. All I see is the activity icon spinning -