title: Android getIntent() returns the first intent
body: <p>I have developed an application to download a video file and store it in the SD card. In the process I also update the progress and status of the download as a status bar notification using the <code>NotificationManager</code>.</p>
  
  <p>My class called the <code>DownloadTask.java</code> extends the <code>AsyncTask</code>. So here I update the progress using the <code>onProgressUpdate()</code> method where in I use the <code>NotificationManager</code> for the purpose. Everything works like a charm except, on completion of download I want to click the notification to open the specific video file. So this is what i have done:</p>
  
  <pre><code>mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
  
  int icon = android.R.drawable.stat_sys_download_done;
  long when = System.currentTimeMillis();
  
  mNotification = new Notification(icon, "", when);
  mContentTitle_complete = mContext.getString(R.string.download_complete);
  notificationIntent = new Intent(mContext,OpenDownloadedVideo.class);
  notificationIntent.putExtra("fileName", file);
  mContentIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, 0);
  mNotification.setLatestEventInfo(mContext, file, mContentTitle_complete, mContentIntent);
  mNotification.flags = Notification.FLAG_AUTO_CANCEL;
  mNotificationManager.notify(NOTIFICATION_ID, mNotification);
  </code></pre>
  
  <p>Note that the <code>fileName</code> and <code>NOTIFICATION_ID</code> are unique in my case.</p>
  
  <p>The <code>Activity</code> <code>OpenDownloadedVideo.java</code> opens the file by:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      try {  
          fileName = getIntent().getExtras().getString("fileName");
          Intent i = new Intent(Intent.ACTION_VIEW);
          File videoFileToPlay = new File(Environment.getExternalStorageDirectory()+"/MyFolder"+"/"+fileName);
          i.setDataAndType(Uri.fromFile(videoFileToPlay), "video/*");
          startActivity(i);
          finish();
      } catch(Exception e) {
          //
      }
  }
  </code></pre>
  
  <p>So when I download a video for the first time and click on the notification the appropriate video file will be opened.  However next time when I download another video, and click on the notification the first file which was downloaded will be opened again.</p>
  
  <p>This is because <code>getIntent</code> inside <code>OpenDownloadedVideo</code> returns the first <code>Intent</code> created and not the latest.  How can I correct this?</p>
  
  <p>Also, please note that the problem scenario exists when I download more than one video, e.g. if I download five different video files and there are five notifications in the status bar. The same file will be opened each time a notification is clicked.</p>