In my app I need to loop through the rows in a DB and for every row
create a notification. Each notification has an intent to open an
activity in my app. How the activity gets handled is dependent on the
extras on the intent.

Here is the code in question

For every row in the database loop{

  Intent notificationIntent = new Intent(context, DisplayScore.class);
                                        notificationIntent.putExtra("sport_id", 
sport);
                                        notificationIntent.putExtra("game_url", 
gameURL);

                                 // The PendingIntent to launch our activity if 
the user selects
this notification
                                PendingIntent pendingIntent = 
PendingIntent.getActivity
(context, 0, notificationIntent, 0);

                                    nm = 
(NotificationManager)context.getSystemService
(Context.NOTIFICATION_SERVICE);
                                    Notification notification = new 
Notification(R.drawable.icon,
                                                "Score update", 
System.currentTimeMillis());

                                        
notification.setLatestEventInfo(context, "My app name", "My
message", pendingIntent);

                                    nm.notify(gs.getMatchID(), notification);

}

The notifications get displayed fine. The problem is that when there
are multiple intents displayed, clicking on them does the same thing
for each one.

What should happen is that the intent being used should have different
extras attached. But it appears as though no matter which notification
is clicked the all send the same intent.

I've checked in the debugger and the intent getting passed to the
notification as the pending intent has the correct extras attached.
But then when it gets clicked its sending the intent (plus extras) of
the first notification in the list to the activity. What am I doing
wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to