I think you are perhaps somewhat confused by how alarm time is specified.
RTC_WAKEUP and RTC type alarm expect time to be specified in
milliseconds since January 1, 1970 00:00:00, in the UTC time zone.
How you construct that time is up to you, and this is where (I believe)
your code goes wrong.
You are specifying date/time values in your time zone (let's assume
that's GMT+4, although it's not), by looking at a clock you have
somewhere around the house, and adding perhaps a few minutes so you can
test.
At the same time, you are telling Calendar that the date / time values
you pass in are in UTC (or GMT) time zone - whereas they are not, they
are in your local time zone, where your clock is.
See the mix-up?
You need to use the time zone you're in when constructing Calendar.
Better yet, as a quick test, call System.currentTimeMillis(), add 1000 *
60 * 5 (just to pick five minutes) and set RTC_WAKEUP with the resulting
value.
This should let you make sure that the rest of your code (the broadcast
receiver, the manifest) is correct.
Hope this helps.
-- Kostya
29.11.2010 21:20, Tez пишет:
I have tried using GMT as well. no use.
Something is wrong in my understanding of how this works.
Can anyone help?
On Nov 29, 5:21 pm, Kostya Vasilyev<[email protected]> wrote:
This looks suspect:
TimeZone.getTimeZone("UTC")
Unless you are actually in that time zone....
-- Kostya
29.11.2010 19:00, Tez пишет:
Hi,
I need to set an alarm clock for, say, 9AM
so I am getting a calendar instance
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
cal.set(2010, 11, 29, 9, 0, 0);
and then I call AlarmManager.set like:
mAlarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTime().getTime(),
pi);
where pi is a pending intent for a broadcast message.
I do not receive a callback at the specified time.
How do I correct this?
Cheers,
Earlence
--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en