AppWidget からのボタンクリックでアクティビティを起動しています。ユーザーはアクティビティにデータを入力し、ユーザーがアクティビティを閉じると、AppWidget の TextView にユーザーが入力したデータを更新したいと考えています。それを行う方法はありますか?AppWidget からアクティビティを正常に開始しましたが、AppWidget の更新だけが問題です。
2 に答える
4
RemoteViews
とを使用できますAppWidgetManager
。
AppWidgetManager manager = AppWidgetManager.getInstance(context);
RemoteViews remoteViews = new RemoteViews(
context.getPackageName(), R.layout.widget);
remoteViews.setTextViewText(R.id.textBoxId, "new textbox content");
manager.updateAppWidget(appWidgetId, remoteViews);
于 2010-07-30T15:46:21.400 に答える
0
ホスト アプリケーションのアクティビティまたはフラグメントから appwidget update メソッドを呼び出すことができます。
これが私がやった方法です:
int[] ids = AppWidgetManager.getInstance(getApplication()).
getAppWidgetIds(new ComponentName(getApplication(), MyWidget.class));
MyWidget myWidget = new MyWidget();
myWidget.onUpdate(this, AppWidgetManager.getInstance(this),ids);
于 2018-07-16T17:44:39.143 に答える