There are Wifi-specific broadcast actions you can register your widget for,
and only update when there is a change. Thesw include: a change in signal
level, connection state, etc.

This way your code can avoid burning through the battery and still display
the information you want.

Also, take a look here:

http://kmansoft.wordpress.com/sw

29.05.2010 1:53 пользователь "Dirk Vranckaert" <[email protected]>
написал:

I think String is right about that. I wouldn't do that either just to
save battery life!

However I think it is better to set the update interval of the applet
to a high enough amount of time (like 24 hours or sth) and just update
the widget manually. I'm currently working on a widget to and in my
case the widget only receives an update upon clicking a certain
button.

The way I do that is like this:

RemoteViews rv = new RemoteViews(context.getPackageName(), WIDGET);
rv.setTextViewText(R.id.textField, "Updated value for some text on the
widget");
ComponentName cn = new ComponentName(context, YourActivity.class);
AppWidgetManager mgr = AppWidgetManager.getInstance(context);
mgr.updateAppWidget(cn, rv);

That should basically work to update a widget.
Oh and one tip: using the this method you should do all updating just
after the line "rv.setTextViewText(...)". If you execute this entire
block a few times after each other you can get into troubles when
updating the widget.

Dirk


On 28 mei, 23:40, String <[email protected]> wrote:
> Before you get too far into this, you ...

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