3

I created a Calendar using the Calendar Provider for Android. I have got it all working fine and I even get the reminders working:

public static ContentValues getReminderContentValues(long eventId) {
        ContentValues cv = new ContentValues();
        cv.put(CalendarContract.Reminders.EVENT_ID, eventId);
        cv.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
        cv.put(CalendarContract.Reminders.MINUTES, 15);
        return cv;
    }

With the above code, I am able to see the events in the default calendar application, Google Calendar and also my application.

I also get a notification 15 minutes before the scheduled start. Now I want to customize the notification in a sense that when I click on the notification, it would go to my app instead of the default calendar application or Google calendar.

I have tried to register a broadcast with the ACTION_EVENT_REMINDER in the manifest like:

    <receiver android:name=".receivers.ReminderReceiver">
        <intent-filter>
            <data android:scheme="content" />
            <action android:name="android.intent.action.EVENT_REMINDER" />
        </intent-filter>
    </receiver>

With this, I am able to get the code in the onReceive method of the broadcast receiver but if I write a notification there too, then I will have 2 notifications being displayed. One which works fine while the other which takes me to default application upon click.

Any solution as to how could I get the reminder notification to open my app or to block the default reminder notification and create a new one altogether?

An alternate solution would be schedule an alarm with the help of AlarmManager on the exact time of the event, but since there will be many such intents, they will basically override each other! Any solution to this?

Tejas Sherdiwala
  • 750
  • 8
  • 15

0 Answers0