I had the same problem and found a way to solve it:
1. To be able to distinguish several instances of the same AppWidgetProvider, when registering an event (intention) onClick, you must add an additional value with the widget identifier (appWidgetId):
Intent clickIntent = new Intent(context, DigiStation.class); clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, appWidgetId, clickIntent, 0);
2.Update only representations of the current instance:
appWidgetManager.updateAppWidget(appWidgetId, views);
3.Android reuses intentions, so when you create an intent, make sure you put a unique identifier, or the same intention that was used earlier will be triggered for all instances:
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, appWidgetId, clickIntent, 0);
4. When processing the click event, get appWidgetId from the "additional functions" payload. You can find more useful information here .
hasanghaforian
source share