【问题标题】:How to Add an event in Google Calendar from Activity?如何从活动中添加谷歌日历中的活动?
【发布时间】:2012-01-18 17:42:31
【问题描述】:

我尝试使用内容提供程序,但该事件未添加到日历中。

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);

【问题讨论】:

    标签: android events google-calendar-api


    【解决方案1】:

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

    从 Android 4.0 开始,这种做法发生了变化,同时打破了对 here 所记录的不受支持的方式的支持。这已被用于 ICS 及更高版本的官方 API 取代,该 API 记录在 here

    【讨论】:

      猜你喜欢
      • 2015-06-20
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      • 2014-12-31
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多