Skip to content Skip to sidebar Skip to footer

Calendar Events And Alarmmanager Service In Android

I'm trying to create an application as follows: The user inserts an event time and sets some actions to be done in this time like turning the phone to vibration mode in this period

Solution 1:

As far as I am aware, and I could be wrong, since the Calendar is not truly implemented at the Operating System level you can not tie directly into event triggers (Reminders, etc.) that you see on your phone when Events are coming up.

More or less, the Calendar app native to a phone is implemented by the device maker (HTS, Motorola, etc.), which means that the event trigger BroadCast Receiver (or Service) is not something you can tie into.

This will be different in Ice Cream Sandwich I believe as the Calendar API is being introduced....there aren't many 4.0 devices out there yet.

Solution 2:

This broadcast receiver works on my phone at least (have not tested others).

A. Using receiver in manifest.xml

<receiverandroid:name=".MyRemindersReceiver" ><intent-filter><dataandroid:scheme="content" /><actionandroid:name="android.intent.action.EVENT_REMINDER" /></intent-filter></receiver>

B. Using receiver in code

IntentFilterinFilter=newIntentFilter(CalendarContract.ACTION_EVENT_REMINDER);
    inFilter.addDataScheme("content");
    registerReceiver(myRemindersReceiver, inFilter);

Looking at this broadcast message in the debugger, it seems that this message has no extras in bundle. However it has a Uri in intent.getData(), which I assume to be the Uri for the calendar event. So you need to query this uri to get more information about the remainder event.

Post a Comment for "Calendar Events And Alarmmanager Service In Android"