Repeating alarms with AlarmManager and daylight saving / leap years

by lorenz » Tue, 10 Feb 2009 06:40:09 GMT

Sponsored Links

I'm looking for a way to trigger repeated actions. I'd like the user
to be able to choose the intervals at which these actions will be
executed. One should be able to choose from intervals like "Every
Day", "Every Month", and "Every Year". The setRepeating(int, long,
long, PendingIntent) method of the class only
supports a long value for choosing the interval between the execution
of the pending intent. My problem now is, that I can not just compute
the number of milliseconds that "fit into one day", since not all days
have the same length (daylight saving). This is also a problem for the
interval type "year" (leap years).

I had a quick look at the android.os.Handler class, but as I
understood the documentation I'd need to keep a service thread running
for my actions to be executed at some future time. I don't consider
that a good option for my needs ;-)

Is there anything in the API I could configure with a cron expression
or the like?

I was also thinking about scheduling an alarm with the AlarmManager
for a single execution at a given date/time and then having a receiver
that does the rescheduling according to a cron expression attached to
the intent. But I don't know if I just got something completely wrong
here and I'm reinventing the wheel with that approach :-/

Any advice or pointers would be greatly appreciated :-)



Re: Repeating alarms with AlarmManager and daylight saving / leap years

by roberto » Thu, 10 Mar 2011 03:42:02 GMT

 Check out the BuzzBox SDK 

You can actually use a cron string to schedule your task:

        .saveTask(this, "0 8-19 * * 1,2,3,4,5", YourTask.class);

I'm actively working on this, so I would love your personal feedback.


Sponsored Links

Other Threads

1. Why didn't google provide APIs for desktop widgets?

Hi, anyone who  knows why? If I want to do this, is it extensive? Only
change the code in launcher in sdk?

2. FYI: JRuby and Rhino coming to Android

Well, running in command-line mode against a Dalvik VM.  But they're on
their way.
Rhino (i.e. JavaScript):

3. Receive email sdk 1.1

4. Why didn't google provide APIs for desktop widgets?

5. Quick Compass question

6. what's the way to put or access a file on the sdcard

7. Active Idle screen