1. Are you ready for the Galaxy S20? Here is everything we know so far!

Widget opening wrong activity with wrong extras

Discussion in 'Android Development' started by marka971, May 29, 2010.

  1. marka971

    marka971 Newbie
    Thread Starter

    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 (Text):
    1.  
    2. Intent soldierDetailsIntent = new Intent(context, SoldierDetails.class);
    3. soldierDetailsIntent.putExtra(OpenSoldierDetailsIntent.EXTRA_WIDGETID, widgetId);
    4. soldierDetailsIntent.putExtra(OpenSoldierDetailsIntent.EXTRA_UID,soldier.getUID());
    5. PendingIntent pendingSoldierDetailsIntent = PendingIntent.getActivity(context, widgetId, soldierDetailsIntent,Intent.FLAG_ACTIVITY_NEW_TASK);
    6. views.setOnClickPendingIntent(R.id.WidgetTotalScore,
    7. pendingSoldierDetailsIntent);
    8.  
    Thanks
    Markus
     


Loading...

Share This Page

Loading...