Reputation: 11
I have problem with default Android Studio app Widget (NEW→XML→WIDGET→APP WIDGET) Shortly, default app widget providing by Android Studio works in this way:
I would like to add new feature to this example. Click on widget should one more time open Configure Activity. (in default design there is no possible to open Configure Activity any more).
I tried to search it on Stack overflow but examples I found not work with that default app Widget... ;/
Upvotes: 0
Views: 719
Reputation: 11
Finally, I found the soluton: Multiple Instances Of Widget Only Updating Last widget
In this line was my problem. PendingIntent widgetPendingIntent = PendingIntent.getActivity(context, appWidgetId, widgetIntent, 0);
Put code below in Widget class
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
//Setup onClick
Intent widgetIntent = new Intent(context,PaydayWidgetConfigureActivity.class);
widgetIntent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent widgetPendingIntent = PendingIntent.getActivity(context, appWidgetId, widgetIntent, 0);
CharSequence widgetText = PaydayWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.payday_widget);
remoteView.setTextViewText(R.id.appwidget_text, widgetText);
remoteView.setOnClickPendingIntent(R.id.appwidget_text, widgetPendingIntent);
// Tell the widget manager
appWidgetManager.updateAppWidget(appWidgetId, remoteView);
}
Upvotes: 1