I went an looked at the code (TreKing is right about the image though - if
you post an image link, make sure it's accessible by anyone).

Your bug is here:

AppWidgetManager appWidgetManager =
AppWidgetManager.getInstance(getApplicationContext());
ComponentName componentName = new ComponentName(getApplicationContext(),
Widget.class);
int[] ids = appWidgetManager.getAppWidgetIds(componentName);
Intent update_widget = new Intent();
update_widget.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
update_widget.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
getApplicationContext().sendBroadcast(update_widget);

What this code does is sends an update broadcast to all receivers (== all
widgets) that exist in the system at this time, but using your own set of
widget ids.

Widget ids are not unique to your application, they are assigned globally.
When other widgets see this event, they "think" that the home screen
application is asking them to update their views - in screen cells idetified
by *your* widgets. And that is what you are seeing.

To update your widgets "on demand" - as opposed to from onUpdate - do this:

AppWidgetManager manager = AppWidgetManager.getInstance(context);
ComponentName thisWidget = new ComponentName(context, YourWidget.class);
int[] widgetIds = manager.getAppWidgetIds(thisWidget);

for (int widgetId : widgetIds) {
     RemoteViews updateViews = <build your update here>;
      manager.updateAppWidget(widgetId, updateViews);
}

or

manager.updateAppWidget(thisWidget, updateViews)

if all your widgets have the same visual state at any given time.

You can run this code from anywhere within your application, such as a
BroadcastReceiver that handles clicks on your widget (probably more fitting
than starting an activity without a content view, which immediately
finishes).

Actually, you can handle the PendingIntent for clicks in your
AppWidgetProvider, since it's a subclass of BroadcastReceiver.

-- Kostya

2011/1/15 TreKing <treking...@gmail.com>

> On Thu, Jan 6, 2011 at 7:20 PM, ChemDroid <chinako...@googlemail.com>wrote:
>
>> when I manually update my widget via AppWidgetManager.updateAppWidget
>> my widget shows the power-control-widget for a short moment as seen in
>> this screenshot:
>> http://forum.xda-developers.com/attachment.php?attachmentid=474576&d=1293489008
>>
>
> Results in:
>
> You are not logged in or you do not have permission to access this page.
>> This could be due to one of several reasons:
>>
>>    1. You are not logged in. Fill in the form at the bottom of this page
>>    and try again.
>>
>>
>>    1. You may not have sufficient privileges to access this page.
>>
>>
>>    1. If you are trying to post or download, your account may be awaiting
>>    activation or you may need to register.
>>
>>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>  --
> 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to