0

I developing small application widget and have some problem with updating of remote views. When widget updating through system call all is ok, but when I trying update widget from my service through this code:

AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
ComponentName widgetComponent = new ComponentName(this, NBRBAppWidget.class);
int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
Intent update = new Intent();
update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
sendBroadcast(update);

my widget view glitches. Example of glitch is on the video below

Video of RemoteView glitches

I checked that update views method took 7-20ms

If anybody has some assumption why this happening, please give me to know.

Community
  • 1
  • 1
Beyka
  • 1,372
  • 1
  • 10
  • 15

1 Answers1

0

To avoid glitch of widget I just remove sending of ACTION_APPWIDGET_UPDATE broadcast and call RemoteView instead of it, like this:

AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
ComponentName widgetComponent = new ComponentName(this, NBRBAppWidget.class);
int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
for (int i = 0; i < widgetIds.length; i++) {
    NBRBAppWidget.updateWidget(this, widgetManager, widgetIds[i]);
}

NBRBAppWidget.updateWidget is method that do calls to remote views

Beyka
  • 1,372
  • 1
  • 10
  • 15