Failed to get broadcast android.intent.action.EVENT_REMINDER

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

+7
source share
5 answers

Well, what are you trying to do, this is not part of the Android SDK, mainly because the calendar is not part of the operating system.

At the same time, at least you need to add a <data> element to your <intent-filter> , since Intent has a Uri .

However, I am sure that this will not work, since Intent also specifically identifies the component ( com.android.calendar/.AlertReceiver ). AFAIK, which was at the beginning of Intent , and therefore Intent will be delivered only to this component, ignoring all other routing rules. Perhaps the specified component appeared only after Intent permission, but I don’t think how these log entries work.

+1
source

You need to set the data schema to β€œcontent” in the intent filter.

Using the manifest, add the data item inside the intent filter

  <receiver android:name="com.eshayne.android.CalendarTest"> <intent-filter> <data android:scheme="content"/> <!-- this was missing --> <action android:name="android.intent.action.EVENT_REMINDER" /> </intent-filter> </receiver> 

Using the code, add a datascheme in one function call

 IntentFilter filter = new IntentFilter(CalendarContract.ACTION_EVENT_REMINDER); filter.addDataScheme("content"); // this was missing registerReceiver(myRemindersReceiver, filter); 
+4
source

You can make the broadcast intent "android.intent.action.EVENT_REMINDER" work by specifying DataAuthority and DataScheme in your intent filter along with your intentional action. You need to specify DataAuthority as "com.android.calendar" and DataScheme as "content".

0
source

broadcast intent "android.intent.action.EVENT_REMINDER" is triggered only when an alert notification should be sent for reminder

0
source

set a notification for your event (for example: 10 minutes before the event) to use the broadcast intent "android.intent.action.EVENT_REMINDER" to work

0
source

All Articles