Luke,

I guess you are setting your alarm with one of xxx_WAKEUP constants in
AlarmManager. Those wake the device up at appropriate times, as specified in
the docs.

Switch to the constants that don't have _WAKEUP (i.e. ELAPSED_REALTIME or
ELAPSED_RTC) so the phone is not waken up from sleep mode to deliver the
alarms.

As for the home app being visible or not, I don't believe you can check for
that. However, not waking the device up should already give you a huge
improvement in battery consumption.

-- Kostya

2011/1/12 Luke <[email protected]>

> Hi all,
>
> I'm developing what amounts to an RSS homescreen widget that
> periodically (every few hours) downloads headlines from an RSS feed,
> then displays each headline in the widget one at a time, cycling to a
> new item every 10 seconds.
>
> All this functionality is working correctly, however watching some log
> statements generated by the widget on the DDMS console, I see that
> even when the homescreen of the device is not displayed (either
> another application is in the foreground, or the display itself is
> asleep), the widget content is still cycling every 10 seconds.  This
> is obviously a concern for battery life.
>
> Currently I'm using an AlarmManager to handle the cycling of the
> widget content at this 10 second interval, but I have no idea how to
> suspend the alarm when the homescreen is not displayed or the device
> is asleep.  I have scoured the documentation, but cannot find any
> obvious event I can listen for or API I can query to find out if the
> homescreen is currently displayed or not.
>
> Google's "News and Weather" widget that comes out of the box with
> Froyo has similar functionality to the widget I'm developing, but it
> does seem to stop cycling through news items when the homescreen is
> not in the foreground or the screen is off.
>
> Any help on how to achieve this would be greatly appreciated!
>
> Regards,
>
> Luke.
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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

Reply via email to