• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Widget opening wrong activity with wrong extras

marka971

Newbie
Hi,

I have developed an app that enables the user to put several widgets of the same kind on the homescreen, but with different data in them depending on a setting in the widget conf activity. When the user clicks a widget, an activity should show up with data according to which instance of the widgets that was pressed. An activity is opened when I press a widget, but it doesn't seem to realize which widget was pressed. Any idea what could be wrong? This is how I set up the pending intent to open the activity:

Code:
Intent soldierDetailsIntent = new Intent(context, SoldierDetails.class);
soldierDetailsIntent.putExtra(OpenSoldierDetailsIntent.EXTRA_WIDGETID, widgetId);
soldierDetailsIntent.putExtra(OpenSoldierDetailsIntent.EXTRA_UID,soldier.getUID());
PendingIntent pendingSoldierDetailsIntent = PendingIntent.getActivity(context, widgetId, soldierDetailsIntent,Intent.FLAG_ACTIVITY_NEW_TASK);
views.setOnClickPendingIntent(R.id.WidgetTotalScore,
pendingSoldierDetailsIntent);

Thanks
Markus
 
Back
Top Bottom