I would like to write an application that starts when a calendar reminder occurs. I understand that it is not officially registered to do this, but I saw in the log that when my phone alarm goes off on my phone (Droid X), AlertReceiver indicates that it received android.intent.action.EVENT_REMINDER:
01-03 11:03:00.029 D 1523 AlertReceiver onReceive: a=android.intent.action.EVENT_REMINDER Intent { act=android.intent.action.EVENT_REMINDER dat=content://com.android.calendar/129407058000 flg=0x4 cmp=com.android.calendar/.AlertReceiver (has extras) }
So, I created a simple BroadcastReceiver:
package com.eshayne.android; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class CalendarTest extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { android.util.Log.i("CalendarTest", "CalendarTest.onReceive called!"); } }
with this manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.eshayne.android" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.READ_CALENDAR" /> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <receiver android:name="com.eshayne.android.CalendarTest"> <intent-filter> <action android:name="android.intent.action.EVENT_REMINDER" /> </intent-filter> </receiver> </application> <uses-sdk android:minSdkVersion="8" /> </manifest>
Unfortunately, when I put it on my phone and set up a calendar event with a reminder - when the reminders remind, I still see the AlertReceiver journal entry, but not mine.
I also read here about some of the intentions of the system, which require registration through code, and not in the manifest. So, I tried the following:
package com.eshayne.android; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; public class CalendarTestDisplay extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { android.util.Log.i("CalendarTestDisplay", "received broadcast"); } }, new IntentFilter("android.intent.action.EVENT_REMINDER")); } }
with this modified manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.eshayne.android" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.READ_CALENDAR" /> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".CalendarTestDisplay" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="8" /> </manifest>
without a better result.
Any ideas what I might be missing? Or any other ideas on how I can capture calendar events?
Thanks Ethan