Saturday, June 5, 2010

[android-developers] Re: How to make a widget that doesn't drain the battery and updates often

> Frankly, I don't know why the Genie... service sticks around for the
> stock News and Weather. It does not appear to be affecting the
> thoroughly irritating and non-configurable
> change-the-headline-every-five-seconds feature, as that persists even
> when I shut down the service via the Settings application.

Neither do I, but it seems "everyone" is taking this approach. I
really really miss guidelines on Android development. Both GUI design
guidelines (toolbars at the bottom anyone?) and design guidelines for
widgets doing more advanced things than updating a clock. It must be
100 different toolbars out there at the moment in various sizes. Why
can't we have a proper toolbar in Android? Sorry, off-topic :-)

> > So is this really the best solution to have a service running in the
> > background?
>
> Probably not.

I would love to see some better suggestions :-)

> If you are using a WakeLock, double-check to confirm you are releasing
> it properly.
No wake-locks. Only using the following code to make the widget change
headline:
...
am.set(AlarmManager.RTC, System.currentTimeMillis() + 5000,
pendingIntent);
...

According to the documentation this should work just brilliant. But my
phone is dead every morning with my widget running. Uninstalled!

> ... to see who is messing up.

Well, people will blame my widget even if I try to tell them that they
have another application that has wake_locks so I must make my widget
behave nicely with the rest of the apps out there.

Well I have made a new service that runs all the time and receives
broadcast events for screen off and on and that works great, so maybe
I'll stick with this. When I have started 10 of my favourite apps I
have a lot of services running so I guess people are used to this.
Seems like services is a bit overused these days so no wonder everyone
complains about battery life with Android...

-Christer


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment