如何在活动中添加Google日历中的活动?

use*_*296 11 events android google-calendar-api

我尝试使用内容提供商,但事件未添加到日历中.

final ContentResolver cr = ctx.getContentResolver();

ContentValues cv = new ContentValues();    
cv.put("calendar_id", l_calId);    
cv.put("title", title);    
cv.put("description", description);    
cv.put("dtstart", millis1 );    
cv.put("hasAlarm", 1);   
cv.put("dtend", millis2);    
cv.put("eventLocation", "Hall: "+location);    
cv.put("transparency", 1);    
cv.put("hasAlarm", 1);    


Uri newEvent ;    
if (Integer.parseInt(Build.VERSION.SDK) == 8 )    
    newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv);    
else    
    newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv);
Run Code Online (Sandbox Code Playgroud)

小智 7

假设您要将事件添加到用户的日历中,请在此处描述在Android 2.x上执行此操作的(不受支持的)方式.

从Android 4.0开始,实践发生了变化,同时打破了对此处记录的不支持方式的支持.这已被ICS及其后续工作的官方API取代,此处记录在案.