Android Calendar Provider不返回最新数据 [英] Android Calendar Provider does not return latest data
问题描述
我正在使用以下代码:
String selection = "((dtstart >= " + now
+ ") AND (dtend <= " + endTime.getTimeInMillis() + "))";
Cursor cursor = context.getContentResolver()
.query(Uri.*parse*("content://com.android.calendar/events"),
*PROJECTION*, selection,null, null);
而且我注意到,一旦我在设备上的Google日历应用中添加/删除了Event
并立即运行以上代码,偶尔就不会从Cursor
获取最新的数据集.我必须手动刷新Google日历应用程序才能获取最新数据.
And I notice that once I add/remove an Event
to Google Calendar app on the device and run the above code immediately, occasionally I do not get the latest dataset from the Cursor
. I have to manually refresh the Google Calendar app to get the latest data.
我错过了什么吗?我可以使用其他一些API吗?
Am I missing something? Can I use some other APIs?
谢谢!
推荐答案
您是对的.由于某些原因,无论是错误还是功能". -过去4-5个月内,Google日历提供程序只有在与服务器同步后,才通过CalendarContract公开更改.
You are right. From some reasons, whether it's a bug or a "feature" - Google calendar provider in last 4-5 months DOES NOT expose changes via CalendarContract until after they have synced with their server.
在不是这样之前,所有更改都可以通过CalendarContract立即用于第三方应用程序-现在仅在同步之后.这很烦人...除非您在Google日历应用中手动执行同步,否则您永远都不知道自己是否有新数据(或者您可以等到自动同步触发器-可能在几秒钟,几分钟或几小时之内,但不在您的计算机中手).
Before it was not like this, all changes were instantly available for 3rd party apps via CalendarContract - now only after syncing. It is very annoying...You never know if you have fresh data unless you manually perform synchronizing in Google Calendar app (or you can wait until auto-syncing triggers - which can be within seconds, minutes or hours, it is not in your hands).
如此愚蠢,愚蠢的变化.经典Google.他们已经搞砸了很多事情,这只是另一件事.它们只是使开发人员的生活复杂化.
Such a stupid, stupid change. Classic google. They screwed up so many things already, this is just another one. They just complicate life for devs.
这篇关于Android Calendar Provider不返回最新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!