我有一个servive,它在单击窗口小部件上的按钮时启动(具有待定意图),并且在服务中我对窗口小部件的视图和数据库中的一些文本进行了一些更改,问题就是一切除了视图的东西,它没有改变任何东西,这是代码
private Intent serviceIntent;
private RemoteViews remoteViews;
private AppWidgetManager appWidgetManager;
private int widgetId;
private DataHelper dh;
@Override
public void onStart(Intent intent, int startId) {
this.serviceIntent = intent;
widgetId = serviceIntent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)[0];
dh = new DataHelper(getApplicationContext());
appWidgetManager = AppWidgetManager.getInstance(this.getApplicationContext());
remoteViews = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.widget_layout);
remoteViews.setTextViewText(R.id.tvText, "Text 1");
remoteViews.setViewVisibility(R.id.progressBar1, View.VISIBLE);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
// some writings in the database
}
即使我正在调用appWidgetManager.updateAppWidget,它仍然没有更新任何内容,任何想法?