Repeating alarms with AlarmManager and daylight saving / leap years

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


Sponsored Links
 Hey

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 android.app.AlarmManager 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 :-)

Cheers
Lorenz

--~--~---------~--~----~------------~-------~--~----~



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  http://hub.buzzbox.com/android-sdk/ 

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

SchedulerManager.getInstance()
        .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.
Roberto

-- 


Sponsored Links


Other Threads

1. 螒蟺: google-api-client + Buzz + OAuth2 + auth token

Any idea, anyone?

-g.

-- 

2. Root MyTouch 4G

Dear all,

mau tanya langkah2 untuk root dan kawan2nya yg paling update yang mana yah ?

Apakah yg http://forum.xda-developers.com/showthread.php?t=858996

<http://forum.xda-developers.com/showthread.php?t=858996>atau yg
http://wiki.cyanogenmod.com/index.php?title=TMobile_myTouch_4G:_Full_Update_Guide

<http://wiki.cyanogenmod.com/index.php?title=TMobile_myTouch_4G:_Full_Update_Guide>Lalu
maksudnya Engineering Bootloader buat apa yah ? Bisa tahunya sudah atau
belum ada kah caranya ?

Thanks

-- 
Rgds,

Petra Immanuel

-- 
"

3. list of receiver that i can a declare in manifest

4. Whether NeofreeRunner is compatible with android 2.3

5. Fwd: Many apps disappeared in Android Market this morning

6. porting android on to panda/beagle board

7. Android get attached filename from gmail app