Hi.

I want to make (yet another) news widget. Initially I thought it was
enough to:
1. Download all the news articles
2. Update the widget every 5 seconds to change the currently displayed
article using AlarmManager (AlarmManager.RTC)
3. Update the widget every 30-60 minutes to get new articles

This worked great on the first try but battery was quickly drained. I
checked the logs and it turned out that the widget did the 5 second
updates even if the screen was off. This was a surprise to me since
the docs states:

"..set an alarm with an Intent that your AppWidgetProvider receives,
using the AlarmManager. Set the alarm type to either ELAPSED_REALTIME
or RTC, which will only deliver the alarm when the device is awake. "

I guess the device is considered "awake" even if screen is off? I
found the same issue here:
http://groups.google.com/group/android-developers/browse_thread/thread/31d4d66f921b7e4c/8abe098d7d4dac96?lnk=gst&q=widget+alarmmanager#8abe098d7d4dac96

I then checked the standard news widget and the other news widgets
most popular on the Android Market and I see that they have services
running all the time. Maybe because they want to handle the broadcast
event when the screen is turned off?

So is this really the best solution to have a service running in the
background? So if someone downloads 10 different news widgets from
different companies they end up with a list of 10 services in the
"Running services" list?

Any help is very appreciated.

Regards,
Christer

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