sendBroadcast is not how you update a widget on demand (I.e. in response to
some data or state change).

I just posted a code example of this, check recent messages, the original
question referenced Power Controls.

--
Kostya Vasilyev -- http://kmansoft.wordpress.com
14.01.2011 16:24 пользователь "joovam" <[email protected]> написал:
> Hi, I'm trying to update the widget whenever it receives a broadcast
> message by sending appropriate intent.
> However after receiving a broadcast message and sending intent it
> doesn't do any job implemented in onUpdate()
> Is it because I'm using the same class?
>
> Sample code looks like this:
>
> public class Example extends AppWidgetProvider {
> public void onUpdate(...) {
> ... do some job
> }
> public void onReceive(Context context, Intent intent) {
> if
> (intent.getAction().equalsIgnoreCase(Intent.ACTION_TIME_CHANGED)) {
> Intent message = new Intent();
> message.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
> message.setClass(context, Example.class);
> <-------------------------------------------------------- HERE!
> context.sendBroadcast(message);
> } else {
> super.onReceive(context, intent);
> }
> }
> }
>
> --
> 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