Re: [android-developers] How register weekly alarm?

409 views
Skip to first unread message
Message has been deleted

Mark Murphy

unread,
Oct 26, 2010, 1:56:51 AM10/26/10
to android-d...@googlegroups.com
On Tue, Oct 26, 2010 at 1:50 AM, Tim <tim....@gmail.com> wrote:
> Hi Guys,
>
> "AlarmManager.setRepeating()" can be set with "interval". But the max
> available interval is daily - "INTERVAL_DAY". So, how to set weekly/
> monthly/yearly interval?

INTERVAL_DAY is used with setRepeatingInexact().

setRepeating() takes a number of milliseconds. I am not aware of any
upper limit on the value. That being said, AFAIK, it is not designed
for long intervals (e.g., yearly).

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 2.2 Programming Books: http://commonsware.com/books

Tim

unread,
Oct 26, 2010, 2:06:50 AM10/26/10
to Android Developers
Thanks Mark.
I am using "INTERVAL_DAY"with "setRepeating(...,long interval,...)".
Still, any workaround/solution for weekly alarm?

On Oct 26, 1:56 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Tue, Oct 26, 2010 at 1:50 AM, Tim <tim.ka...@gmail.com> wrote:
> > Hi Guys,
>
> > "AlarmManager.setRepeating()" can be set with "interval". But the max
> > available interval is daily - "INTERVAL_DAY". So, how to set weekly/
> > monthly/yearly interval?
>
> INTERVAL_DAY is used with setRepeatingInexact().
>
> setRepeating() takes a number of milliseconds. I am not aware of any
> upper limit on the value. That being said, AFAIK, it is not designed
> for long intervals (e.g., yearly).
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

Mark Murphy

unread,
Oct 26, 2010, 2:12:38 AM10/26/10
to android-d...@googlegroups.com
On Tue, Oct 26, 2010 at 2:06 AM, Tim <tim....@gmail.com> wrote:
> Thanks Mark.
> I am using "INTERVAL_DAY"with "setRepeating(...,long interval,...)".

INTERVAL_DAY is used with setRepeatingInexact(). The value happens to
be correct for use with setRepeating(), though.

> Still, any workaround/solution for weekly alarm?

If it is not working for you, then wake up every day and see if a week
has passed. Or, use set() to schedule an alarm for a week from now,
and have that alarm call set() to schedule another alarm a week in the
future.

--

Message has been deleted

Tim

unread,
Oct 26, 2010, 5:09:12 AM10/26/10
to Android Developers
I have a mistake. Actually, weekly alarm works with interval set to
"7*INTERVAL_DAY".

The question changed to "how make monthly/yearly alarm"?

Thanks!

On Oct 26, 2:12 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Tue, Oct 26, 2010 at 2:06 AM, Tim <tim.ka...@gmail.com> wrote:
> > Thanks Mark.
> > I am using "INTERVAL_DAY"with "setRepeating(...,long interval,...)".
>
> INTERVAL_DAY is used with setRepeatingInexact(). The value happens to
> be correct for use with setRepeating(), though.
>
> > Still, any workaround/solution for weekly alarm?
>
> If it is not working for you, then wake up every day and see if a week
> has passed. Or, use set() to schedule an alarm for a week from now,
> and have that alarm call set() to schedule another alarm a week in the
> future.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

Mark Murphy

unread,
Oct 26, 2010, 2:30:47 PM10/26/10
to android-d...@googlegroups.com
On Tue, Oct 26, 2010 at 5:09 AM, Tim <tim....@gmail.com> wrote:
> I have a mistake. Actually, weekly alarm works with interval set to
> "7*INTERVAL_DAY".
>
> The question changed to "how make monthly/yearly alarm"?

I would not implement a monthly/yearly alarm via AlarmManager.

--

Reply all
Reply to author
Forward
0 new messages