Multiple Expected Intent

I created a widget that, when clicked, activates PendingIntent. The problem is that when I have more than one widget on the screen, only the last one will launch PendingIntent.

I read a few about the unique request code, but did not understand this.

Any ideas how I can have multiple widgets and PendingIntents work for each?

Here is a snippet of my code:

Intent openApp = new Intent(context, RunningTally.class); openApp.putExtra("widgetId", appWidgetId); PendingIntent pendingAppIntent = PendingIntent.getActivity(context, 0, openApp, PendingIntent.FLAG_CANCEL_CURRENT ); views.setOnClickPendingIntent(R.id.openFull, pendingAppIntent); 
+49
android widget
Sep 16 '10 at 19:52
source share
1 answer

It so happened that after the publication of my question, I came up with an answer. I pass my appWidgetId as a "unique" request code and voila! Here is a snippet:

 Intent openApp = new Intent(context, RunningTally.class); openApp.putExtra("widgetId", appWidgetId); PendingIntent pendingAppIntent = PendingIntent.getActivity(context, appWidgetId, openApp, PendingIntent.FLAG_CANCEL_CURRENT); views.setOnClickPendingIntent(R.id.openFull, pendingAppIntent); 
+108
Sep 16 '10 at 20:10
source share



All Articles