Skip to content

Instantly share code, notes, and snippets.

@dmitriy-chernysh
Last active August 29, 2015 14:14
Show Gist options
  • Save dmitriy-chernysh/061539eb31ea41539dc8 to your computer and use it in GitHub Desktop.
Save dmitriy-chernysh/061539eb31ea41539dc8 to your computer and use it in GitHub Desktop.
Android Widget UI Update
public class Widget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
final int countWidgets = appWidgetIds.length;
for (int i = 0; i < countWidgets; i++) {
int appwidgetId = appWidgetIds[i];
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
//TODO: update UI
//...
//update widget
appWidgetManager.updateAppWidget(appwidgetId, remoteViews);
}
}
// other methods
//....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment