Just update a widget RemoteViews instead of completly creating a new one?

前端 未结 3 1712
傲寒
傲寒 2021-02-10 07:35

So in my onUpdate method in my AppWidgetProvider class, I ended up executing a non-trivial amount of code so that I can completely recreate a new RemoteViews object. The reality

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-10 07:55

    You can update the remote views and then call

    ComponentName componentName= new ComponentName(context, YourClass.class);
    AppWidgetManager.getInstance(context).updateAppWidget(componentName, remoteViews);
    

    on, which AFAIK should update the widget

提交回复
热议问题