0

How do I all of the current day's events based on the current date of the phone.

I want to include all day events, reoccurring events, and regular events. I've been everywhere and haven't found a good working example. Some code would be nice. I keep ending up with all day events showing up a day before

MobileMon
  • 8,341
  • 5
  • 56
  • 75
  • What have you tried? If you post some code, you may get more bites on this question. Regarding all-day events: they do appear early. Your device notifies you of them early, too. Your app needs to be aware of this and should check whether an event is for the entire day. – acj Oct 25 '12 at 20:15

2 Answers2

0

Do you still need this? I just coded this if you'd like some help.

Basically it boils down to a few things. If you're using API 14?/15+ you can use the CalendarContract. You'll want to query the instances table, because the event table only includes one entry for sets of recurring events. You'll probably want to get the current time (just a calendar getInstance() will do it) and then get the cutoff time for your search by adding a day to the current time.

You'll find examples in the docs that aren't half bad. You may need some SQL knowledge to pull it off properly. Let me know if you'd like some tips. Once you understand what's going on, it's really easy.

If you're using earlier apis you'll have to look into a bunch of contenturi stuff that I haven't really checked out. I assume they're more trouble, but there will also be more stuff online.

NathanTempelman
  • 1,301
  • 9
  • 34
0

The all-day event problem might be caused by the timezone independence of all-day events. Check by looking at the starting time-of-day for your all-day events - see if it's the same as the difference between your timezone and GMT. If that's the problem, make a separate date/time format with GMT timezone for your all-day events.

    Format dfAllDay = DateFormat.getDateInstance();
    ((DateFormat)dfAllDay).setTimeZone(TimeZone.getTimeZone("UTC"));
brbaker
  • 172
  • 2
  • 9