I am struggling with passing information to the onCreate() method for
a notification activity. The onCreate() is being invoked when I select
the notification entry, but the information passed to it is not always
correct. I am using the putExtra() method when setting up the
notification, but it appears that the data sometimes (but not always)
begin received contains a value from a previous intent. Here are
extracts from the two sides of the notification:

...
private void showNotification(Context context, NotificationManager nm,
int alarmID) {
  Notification notification = new Notification
(R.drawable.greatlogic32x32, "Alarm",
                                               System.currentTimeMillis
());
  Intent intent = new Intent(context,
AlarmNotificationActivity.class);
  intent.putExtra("AlarmID", alarmID);
  PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
  notification.setLatestEventInfo(context, "Alarm title", "Alarm
detail: " + alarmID,
                                  pendingIntent);
  nm.notify(alarmID, notification);
}
...

public class AlarmNotificationActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.alarm_notification_activity);
  Bundle extrasBundle = getIntent().getExtras();
  int alarmID = extrasBundle.getInt("AlarmID");
}
}

The value of alarmID is not usually the same between the creation of
the notification and the onCreate() method that is called when the
notification entry is selected from the notifications list when the
program is executed multiple times.  I have looked at this for hours,
and I would appreciate any guidance on the way I am setting up these
notifications.

Many thanks! Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to