First you need to add this type of receiver to the 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 create 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();
}
}