I have an application since much time ago which listens to events when calendar events change. I did it adding this to manifest:
<receiver android:name="your.package.name.CatchChangesReceiver"
android:priority="1000" >
<intent-filter>
<action android:name="android.intent.action.PROVIDER_CHANGED" />
<data android:scheme="content" />
<data android:host="com.android.calendar" />
</intent-filter>
</receiver>
Then creating a simple class which extends broadcast receiver:
public class CatchChangesReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// add processing here with some query to content provider
// in my project I use this selection for getting events:
final String SELECTION = CalendarContract.Events.CALENDAR_ID + "="
+ calendarId + " AND " + "("
+ CalendarContract.Events.DIRTY + "=" + 1 + " OR "
+ CalendarContract.Events.DELETED + "=" + 1 + ")" + " AND "
+ CalendarContract.Events.DTEND + " > "
+ Calendar.getInstance().getTimeInMillis();
}
}
This had always worked for me, as application exists since years ago. I used to have Samsung devices, where calendar was an application called S Planner. Now I have an Asus Zenfone Max. It has Google Calendar installed. But now this listener doesn't work properly. Since I add a new event until the listener fires up, there is a great delay. Even I think that when I create a calendar event, the listener doesn't launch unless I close and open calendar app several times. The issue is that the listener is launched at some moment, but not when it should be, instead, there is a big delay since I create the calendar event until the listener is called. Why is there such a delay?