tags:

views:

38

answers:

1

Hi All, my target: download files parallel, and when file download completed i have notifications.

those notificaion suppose to launch an activity when you click on it which get unique parameter through putExtra.

problem is that i cant have diffrent values in each launch of that activity.

each time the last activity which being launched through the notification bar, destroying the extra's of the ones which havnt been launched yet(the ones that sill appears on the notificaion bar).

how will i keep all my notification with thire own parameters?

code:

        if (messagesManager == null)
    {
        messagesManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
    }

    notification = new Notification(R.drawable.icon, message, System
            .currentTimeMillis());

    // for launch activity
    Intent intent = new Intent(context, DialogActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("fileName", fileName); //- this is where i put my extra's!!
    intent.putExtra("onSdcard", onSdcard);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
            intent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(context, "DownloadManager", message,
            contentIntent);
    notification.flags = notification.FLAG_AUTO_CANCEL;
    int noticeId = generateNotificationId(requestId);
    messagesManager.notify(noticeId, notification);

now this is the dialog activity:

   protected void onCreate(Bundle savedInstanceState)
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    Intent i = getIntent();
    boolean onSdcard = i.getBooleanExtra("onSdcard", true);
    String fileName = i.getStringExtra("fileName");

... }

i tried to use this technic as it was written in another post here, but it didnt work

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

thanks!!

ray.

A: 

Please check the linked duplicate,

you need two things

  • you need to add an action string
  • the action string must be unique, probably a timestamp added to it would be good
Pentium10