0

我尝试将事件写入网络中的谷歌日历,但此代码仅将我的事件写入语言环境 android 日历。我需要将事件写入两个日历。请帮忙。

public void writeCalendar() {
        ContentValues event = new ContentValues();
        event.put("calendar_id", mCalendarId);    
        event.put("title", "Beaty and fun");
        event.put("description", "This is a simple test for calendar api");
        event.put("dtstart", System.currentTimeMillis());
        event.put("dtend", System.currentTimeMillis() + 1800*1000);
        event.put("allDay", 0);
        event.put("eventStatus", 0);
        event.put("visibility", 0);
        event.put("transparency", 0);
        event.put("hasAlarm", 0);
        Uri l_eventUri;
        if (Build.VERSION.SDK_INT >= 8 ) {
            l_eventUri = Uri.parse("content://com.android.calendar/events");
        } else {
            l_eventUri = Uri.parse("content://calendar/events");
        }
        Uri eventUri =    Resources.instance().getActivity()
                 .getContentResolver().insert(l_eventUri, event);
}
4

1 回答 1

0

您需要使用Google Calendar Api对用户进行身份验证并与 Google 通信。

要添加到两者,您必须为每个日历(本机和 Google)设置 2 个单独的操作,或者如果用户在其设备上下载了 Google 日历,则添加到 Google 日历将与他们设备上的 Google 日历应用程序同步,因此满足你的两个条件。

于 2013-04-02T09:08:54.347 回答