使用BroadcastReceiver和Rrule的Android重复活动

所以我现在正在为
Android开发应用程序.它使手机在特定时间内无声.它现在工作得很好,我想完成它,但还有一件事我想做:我想让事件重复.我已经实现了
this library,我的数据库中有重复规则(rrule).时间和广播接收器也已经在工作.

有没有什么好的方法在互联网上解析一个rrule字符串然后得到下一个重复的一天.我还需要一些用人类语言显示rrule的方法.有人知道这样做的好图书馆吗?

我已经尝试过google rfc-2445和iCal4j,但它们要么没有按预期工作,要么我无法弄清楚如何根据我的需要使用它们.

最佳答案 我为这个确切的情况使用’双周’库,传入一个rrule,然后生成该规则的未来事件.

https://github.com/mangstadt/biweekly

示例:(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());
}
点赞