I have remote views that are updated during their configuration. So far so good.

When later on the state they should monitor changes I want to update
them again and I use the same code to alter the remote views, but
nothing happens. When looking at the remote views in the debugger I
can see that the remote views' mAction instance var does accumulate
all my changes (setTextViewText etc.), but the actual widgets don't
change.

Any idea what might be wrong or where I can look at? I know it is
probably something stupid, but I don't see it and it's not for a lack
of trying.

I tried loads of different approaches, but here is the current code:

firing the update:

AppWidgetManager awm = AppWidgetManager.getInstance(ctx);
int[] appWidgetIds = awm.getAppWidgetIds(new ComponentName(ctx,
UnreadWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
    System.out.println("EM.awm.updateWidget  appWidgetId=" + appWidgetId);
    awm.updateAppWidget(appWidgetId,
UnreadWidgetProvider.buildUpdate(ctx, appWidgetId));
}

create the remote views:

public static RemoteViews buildUpdate(Context context, int appWidgetId) {
        System.out.println("buildUpdate appWidgetId=" + appWidgetId);

        EntryManager entryManager = EntryManager.getInstance(context);
        WidgetPreferences wp = entryManager.getWidgetPreferences(appWidgetId);
        RemoteViews updateViews = new RemoteViews(context.getPackageName(),
R.layout.unread_widget);

        if (wp == null) {
                System.out.println("In configuration. Nothing stored yet for
appWidgetId=" + appWidgetId);
                return updateViews;
        }

        System.out.println("using dbq=" + wp.getDBQuery() + " appWidgetId=" +
appWidgetId);

        int count = getCount(entryManager, wp.getDBQuery());

        System.out.println("count=" + count);
        System.out.println("label=" + wp.getLabel());
        updateViews.setViewVisibility(R.id.unread_count, count > 0 ?
View.VISIBLE : View.INVISIBLE);
        updateViews.setTextViewText(R.id.unread_count, String.valueOf(count));

        System.out.println("wp.getLabel()=" + wp.getLabel() + "!");

        // updateViews.setViewVisibility(R.id.label, wp.getLabel() !=
        // null ? View.VISIBLE : View.INVISIBLE);
        updateViews.setViewVisibility(R.id.label, View.VISIBLE);
        if (wp.getLabel() != null)
                updateViews.setTextViewText(R.id.label, wp.getLabel());

        Intent intent = new Intent(context, ArticleListActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, 
intent, 0);

        updateViews.setOnClickPendingIntent(R.id.unread_count, pendingIntent);
        System.out.println("After setOnClickPendingIntent");

        return updateViews;
}

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