从没有默认提醒我的应用程序创建的日历事件 [英] Create calendar event from my app without default reminders

查看:188
本文介绍了从没有默认提醒我的应用程序创建的日历事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,创建,更新和删除本机谷歌的日历事件。 我按照code创建一个事件:

I am developing an app that creates, updates and deletes events in native Google's calendar. I am creating an event by following code:

ContentValues cvEvent = new ContentValues();
cvEvent.put(Events.DTSTART, startMillis);
cvEvent.put(Events.DTEND, endMillis);
cvEvent.put(Events.TITLE, strJobName);
cvEvent.put(Events.CALENDAR_ID, mlCalendarID);
cvEvent.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uriEvent = crEvent.insert(Events.CONTENT_URI, cvEvent);

但问题是,这一事件造成他的日历(谷歌)在用户设置一个默认的提醒。

But the problem is that this event creates a default reminder as set by the user within his calendar (Google).

我也可以让用户在我的应用程序添加提醒。所以,当他增加了一个提醒,我催插入到默认的谷歌日历。具有没有问题。但是,当用户不加入任何提醒在我的应用程序,默认的谷歌日历创建默认提醒。谁能告诉我怎么解决这个问题呢?

I am also allowing users to add reminders within my app. So, when he adds a reminder, I am inserting reminders into the default Google Calendar. That has no issues. But when user is not adding any reminder in my app, the default google calendar creates default reminder. Can anyone tell me how to solve this issue?

P.S:我没有使用同步适配器我。我创建并通过我自己的逻辑删除的事件和提醒。

P.S: I am not using Sync Adapters. I am creating and deleting events and reminders through my own logic.

我试图用

values.put(Events.HAS_ALARM, 0);

不过,这是没有用的。

But, it is of no use.

推荐答案

如何删除提醒以编程方式使用你插入事件后得到了事件ID?

How about deleting the reminders programmatically using the event ID that you got after inserting the event?

ContentValues cvEvent = new ContentValues();
cvEvent.put(Events.DTSTART, startMillis);
cvEvent.put(Events.DTEND, endMillis);
cvEvent.put(Events.TITLE, strJobName);
cvEvent.put(Events.CALENDAR_ID, mlCalendarID);
cvEvent.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uriEvent = crEvent.insert(Events.CONTENT_URI, cvEvent);

//added code
long eventID = Long.parseLong(uri.getLastPathSegment());
ContentResolver cr = getContentResolver();
cr.delete(Reminders.CONTENT_URI, Reminders.EVENT_ID+"=?", new String[]{eventID+""});

这篇关于从没有默认提醒我的应用程序创建的日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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