如何添加事件从Android应用程序谷歌日历 [英] How to Add event in google calendar from Android Application

查看:342
本文介绍了如何添加事件从Android应用程序谷歌日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何将事件从您的活动添加到您的谷歌日历。我尝试使用内容提供者,但该事件没有被添加到该日历中。 我的code添加事件日历是如下。

Can anyone tell me how to add an event to your google calendar from you activity. I tried using content providers, but the event was not added to the calendar. My code for adding the event to calendar was as below.

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

在此先感谢您的帮助

Thanks in advance for the help

推荐答案

假设你想将事件添加到用户的日历,在Android 2.X做的(不支持)的方式描述的here

Assuming you want to add an event to your users' calendar, the (unsupported) way of doing it on Android 2.x is described here.

,这种做法改变了,同时打破了不支持的方式支持,记录的此处。这被替换由官方API工作ICS和以后被记录这里

As of Android 4.0, the practice changed while breaking support for the unsupported way as documented here. This was replaced by an official API working on ICS and onwards which is documented here.

这篇关于如何添加事件从Android应用程序谷歌日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆