Sunday, June 6, 2010

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

I have two observations/question to supplement what others have
already observed: 1)5 seconds may just be too often: if I had such a
widget on my phone, I would prefer updating every 30 seconds, not
every 5: but in fact, when I find widgets doing such self-updates I
generally uninstall them.. 2) you should go ahead and use wake_locks
yourself -- not to seize resources and turn them on, but to do the
opposite: relinquish screen and network and allow them to go off --
unless someone else's wake_lock is the real culprit keeping them on.

But it it is someone else's that is the culprit there is little you
can do: the best you can do is to make the updates infrequent as I
already suggested.

Finally, the update period is an obvious candidate for a Preferences
Menu.

On Jun 5, 11:38 am, Chister Nordvik <cnord...@gmail.com> wrote:
> > 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