Hello,
In my AppWidgetProvider class, in the onUpdate(...) method, I sort through the array of id's and inside the loop create an intent to launch the activity with information specific to the widget that is being clicked, the intent looks like this:
Intent intent = new Intent(context, MyActivity.class);
intent.putExtra("WIDGET ID", appWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.widget, pendingIntent);
Then, in the activity I collect the extras:
Intent intent = getIntent();
Bundle extras = intent.getExtras();
int id = extras.getInt("WIDGET ID", AppWidgetManager.INVALID_APPWIDGET_ID);
For testing purposes when the activity is launched by clicking on a widget I display the int id from above, but no matter how many widgets I add or which one I click on it always displays the same constant value!
Any ideas??
Thank you!
Matt.
In my AppWidgetProvider class, in the onUpdate(...) method, I sort through the array of id's and inside the loop create an intent to launch the activity with information specific to the widget that is being clicked, the intent looks like this:
Intent intent = new Intent(context, MyActivity.class);
intent.putExtra("WIDGET ID", appWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.widget, pendingIntent);
Then, in the activity I collect the extras:
Intent intent = getIntent();
Bundle extras = intent.getExtras();
int id = extras.getInt("WIDGET ID", AppWidgetManager.INVALID_APPWIDGET_ID);
For testing purposes when the activity is launched by clicking on a widget I display the int id from above, but no matter how many widgets I add or which one I click on it always displays the same constant value!
Any ideas??
Thank you!
Matt.