How to find and select events calendar in Android?
-
I am trying to implement finding and selecting events in calendar on Android Application. I believe that, find and select have completely different implementation. I have scoured the web to no avail. I would appreciate a helping hand.
-
Answer:
manifest <uses-permission android:name="android.permission.READ_CALENDAR" /> These examples are for <= 2.1 version; first; find out which calendars exist Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null); cursor.moveToFirst(); String[] CalNames = new String[cursor.getCount()]; int[] CalIds = new int[cursor.getCount()]; for (int i = 0; i < CalNames.length; i++) { CalIds[i] = cursor.getInt(0); CalNames[i] = cursor.getString(1); cursor.moveToNext(); } cursor.close(); Fetching all events, and particular event is done by specifying range ContentResolver contentResolver = getContentResolver(); Uri.Builder builder = Uri.parse(getCalendarUriBase() + "/instances/when").buildUpon(); long now = new Date().getTime(); ContentUris.appendId(builder, now - DateUtils.MILLIS_PER_DAY*10000); ContentUris.appendId(builder, now + DateUtils.MILLIS_PER_DAY * 10000); and then let's say you wish to log events ID from calendar with ID = 1 Cursor eventCursor = contentResolver.query(builder.build(), new String[] { "event_id"}, "Calendars._id=" + 1, null, "startDay ASC, startMinute ASC"); // For a full list of available columns see http://tinyurl.com/yfbg76w while (eventCursor.moveToNext()) { String uid2 = eventCursor.getString(0); Log.v("eventID : ", uid2); } and for some source code check http://jimblackler.net/blog/?p=151 and http://stackoverflow.com/questions/4302209/android-calendar-events
user788511 at Stack Overflow Visit the source
Related Q & A:
- How to add calendar events in other calendar in Android?Best solution by Stack Overflow
- How to find your location on android programmatically?Best solution by Stack Overflow
- How do I randomly select a string from an array in swift?Best solution by Stack Overflow
- How do I disable the previous dates in Android custom calendar?Best solution by Stack Overflow
- How do I sync my blackberry calendar to my Google calendar?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.