2013-01-11 142 views
0

我添加事件這樣的後...我如何可以同步日曆事件中添加事件

public static String EVENT_URI = "content://com.android.calendar/events"; 
public static String CALENDAR_URI = "content://com.android.calendar/calendars"; 

public static Uri insert(ContentResolver cr, ContentValues cv) { 

    Uri newEvent = null; 

    try { 
     cv.put(Event.CALENDAR_ID, 1); 
     cv.put(Event.TITLE, "title"); 
     cv.put(Event.DESCRIPTION, "description"); 
     cv.put(Event.DTSTART, new Date().getTime()); 
     cv.put(Event.DTEND, new Date().getTime() + 1000 * 60 * 60); 
     cv.put(Event.EVENT_LOCATION, "Hall: " + "+ 1000 * 60 * 60"); 
     cv.put(Event.HAS_ALARM, true); 
     cv.put(Event.EVENT_TIMEZONE, TimeZone.getDefault().getDisplayName()); 

     newEvent = cr.insert(Uri.parse(EVENT_URI), cv); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    return newEvent; 
} 

我想添加事件後,與谷歌日曆同步,有沒有我必須與發送的任何參數ContentValues我需要激發查詢sync

如何有用http://developer.android.com/guide/topics/providers/calendar-provider.html#sync-adapter

幫助!謝謝。

回答