Android Recurring Event with BroadcastReceiver and Rrule

android, broadcastreceiver, recurrence

Solution

I use the 'biweekly' library for this exact case, to pass in an rrule, and then generate the future events for that rule.

https://github.com/mangstadt/biweekly

Example: (https://github.com/mangstadt/biweekly/wiki/Examples#parsing-an-rrule-string)

RecurrenceRuleScribe scribe = new RecurrenceRuleScribe();
ParseContext context = new ParseContext();
context.setVersion(ICalVersion.V2_0);
RecurrenceRule rrule = scribe.parseText("FREQ=WEEKLY;INTERVAL=2", null, new ICalParameters(), context);
Recurrence recur = rrule.getValue();

Date start = ...
TimeZone timezone = ...
DateIterator it = rrule.getDateIterator(start, timezone);
while (it.hasNext()) {
    System.out.println(it.next());
}

Problem

So I am developing an app for Android right now. It sets the phone to loudless in a specific time. It's working quite well right now and I want to finish it up, but there's one more thing I want to do: I want to make the events Recurring. I've already implemented this library and I have the recurrence rule (rrule) in my database. The time and the broadcast receiver is also already working. Is there any good way out there in the internet to parse a rrule string and then get the next recurring day. I would also need some way of display the rrule in a human language. Does anybody know of a good library that does that? I've already tried out google rfc-2445 and iCal4j, but they either didn't work as intended or I couldn't figure out how to use them for my needs.

Original source