4

I am writing an application that needs to know when a meeting is added/removed/changed in the calendar.
I know how to get all the data from a calendar using CursorLoader on the calendar uri.
Also i know how to listen to calendar changes using the ContentObserver.

The problem is that the ContentObserver.onChange(boolean selfChange, Uri uri) does not provide information on the changed event. so the only way for me to know what the change was is to load again the entire calendar (or part of it) using the CursorLoader and comparing the old with the new.

Is there a way to "register for changes" on the calendar and receive the events that were changed?

Eli Skoran
  • 238
  • 1
  • 10
  • follow below link may you got your answer http://stackoverflow.com/questions/15217723/broadcastreceiver-for-android-calendar-events – Damodhar Meshram Jun 07 '15 at 08:55

2 Answers2

3

Unfortunately, there is no such option. I even went as far as to reflect the entire Bundle which came with that Intent - nothing. IMHO, some surfaces of the Android API are quite lacking, this is just one of these instances, I guess.

Eyal Perry
  • 2,255
  • 18
  • 26
0

Each event after manual editing event sets CalendarContract.DIRTY = 1 (used to indicate that local, unsynced, changes are present). Find these events. Don't forget to reset this flag (equal 0) after synchronization.

ilyamuromets
  • 403
  • 1
  • 7
  • 18
  • but can i be sure that this flag will stay 1 by the time i come to handle this event? and also i need to handle a situation in which i read the same object in two separate times (the flag stayed 1 for some events) – Eli Skoran Oct 02 '16 at 06:03
  • Each event has its own CalendarContract.DIRTY flag (default value is "0"). When user edits event, CalendarContract.DIRTY flag takes the value "1" and only you can reset this flag to "0" after the event processing. I use this mechanism for a long time and everything works fine. – ilyamuromets Oct 03 '16 at 07:19
  • does it also works when the calendar is changed on the cloud and synced to the device. – Eli Skoran Oct 16 '16 at 06:43
  • for example if you change the event from your pc (outlook) and it is synced to the device. will it also have DIRTY = 1? – Eli Skoran Oct 16 '16 at 06:46
  • No. DIRTY flag take the value "1" only if you manually change/create event in device and doesn't reset by itself. – ilyamuromets Oct 17 '16 at 12:43