I followed the steps in 
http://mavenlog.wordpress.com/2012/01/22/how-to-adding-a-calendar-in-the-android-ics-emulator/
 to 
add my Gmail account to the built in Calendar app in Android 4.0.3 emulator.
Then, I adpated the code snippet in 
http://developer.android.com/guide/topics/providers/calendar-provider.html to 
create a calendar event in onCreate() of my Activity(with <uses-permission 
android:name="android.permission.READ_CALENDAR" /> and  <uses-permission 
android:name="android.permission.WRITE_CALENDAR" /> permissions).
 
        long calID = 1;
        long startMillis = 0; 
        long endMillis = 0;     
        Calendar beginTime = Calendar.getInstance();
        beginTime.set(2012, 12, 29, 14, 30);
        startMillis = beginTime.getTimeInMillis();
        Calendar endTime = Calendar.getInstance();
        endTime.set(2012, 12, 29, 15, 30);
        endMillis = endTime.getTimeInMillis();
        
        ContentResolver cr = getContentResolver();
        ContentValues values = new ContentValues();
        values.put(Events.DTSTART, startMillis);
        values.put(Events.DTEND, endMillis);
        values.put(Events.TITLE, "Jazzercise");
        values.put(Events.DESCRIPTION, "Group workout");
        values.put(Events.CALENDAR_ID, calID);
        values.put(Events.EVENT_TIMEZONE, "GMT");
        Uri uri = cr.insert(Events.CONTENT_URI, values);
        System.out.println(uri);
 
The uri I got is like content://com.android.calendar/events/6 so the 
creation is successful. 
However, the created event is not visible in the built-in Calendar app. Why?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<<attachment: builtincalendar.png>>

Reply via email to