How to get calendar change events? Is calendar observer working?
<p>I want to receive the calendar change events on android device. I try to register a observer for it, but it's not working. </p>

<p>Do I have to retrieve all the events periodically to know something is changed? </p>

<p>Here're my codes, appreciate for any response.</p>

<pre><code>public class CalendarObserver extends ContentObserver 
{
    public CalendarObserver(Handler handler) {
    super(handler);
    }

    public boolean deliverSelfNotifications() {
        return true;
    }

    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
        Log.i("", "Calendar changes");
    }
}
</code></pre>

<p>Register it on my main activity, but it's not working.</p>

<pre><code>CalendarObserver observer = new CalendarObserver (new Handler());
getContentResolver().notifyChange(
    Uri.parse("content://com.android.calendar/events"), observer);
</code></pre>

<hr>

<p>Also tried ..., but still not working</p>

<pre><code>String[] projection = new String[] { "_id"};
Uri calendars = Uri.parse("content://com.android.calendar/calendars");
//Uri calendars = Uri.parse("content://com.android.calendar/events");
//Uri calendars = Uri.parse("content://calendar/calendars");
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(calendars, projection, null, null, null);
cursor.registerContentObserver(observer);
</code></pre>

<hr>

<p>Also tried to use the intent receiver,  because I saw the following log from logcat,
but it's still not working.</p>

<pre><code> I/CalendarProvider2(13444): Sending notification intent: Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.android.calendar }
</code></pre>

<p>...</p>

<pre><code> CalendarReceiver receiver= new CalendarReceiver ();
 filter = new IntentFilter();
 filter.addAction("android.intent.action.PROVIDER_CHANGED");
 registerReceiver(receiver, filter);
</code></pre>
