Android CalendarContract, deleting a recurring event causes all events to disappear on calendar?

守給你的承諾、 提交于 2019-12-11 02:46:09

问题


I have a sync adapter that handles syncing calendars and events. I am able to delete normal events just fine. But whenever I delete a recurring event, all the events on my calendar disappear.

One thing I noticed is that whenever I deleted a recurring event, the Instances table is emptied, which explains the events disappearing. The Events table is as expected, with the recurring event row deleted from the table.

What is causing this?

I have tried deleting in the following ways:

resolver.delete(
    ContentUris.withAppendedId(Events.CONTENT_URI, id),
    null,
    null
);

resolver.delete(
    Events.CONTENT_URI,
    Events._ID + " = ?",
    new String[]{id}
);

And also as a SyncAdapter:

resolver.delete(
    Events.CONTENT_URI.buildUpon()
    .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
    .appendQueryParameter(Calendars.ACCOUNT_NAME, account.name)
    .appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type)
    .build(),
    Events._ID + " = ?",
    new String[]{id}
);

All methods work correctly on non-recurring events, but all cause the Instances table to be emptied when deleting a recurring event.

Update

One thing I noticed is that the LogCat spits out the following error

  • Application: system_process
  • Tag: BufferQueue
  • PID: 1187
  • TID: 1518

[com.android.calendar/com.android.calendar.AllInOneActivity] BufferQueue:drainQueueLocked: timeout waiting on consumer!


回答1:


It turned out to be an error on my part. When my SyncAdapter was adding calendars to the database, I was not properly setting the field SYNC_EVENTS (http://developer.android.com/reference/android/provider/CalendarContract.CalendarColumns.html#SYNC_EVENTS). Specifically, this field should be set to 1.

It was difficult to know that this was the issue because I was still able to technically "sync" (push events to the server and pull events from the server), but I was just running into the issue my events disappearing.

I hope this helps someone else too.



来源:https://stackoverflow.com/questions/16392410/android-calendarcontract-deleting-a-recurring-event-causes-all-events-to-disapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!