title: Android: Click event for Status bar notification
body: <p>I've got the following code to create a status bar notification:</p>
  
  <pre><code>public void txtNotification(int id, String msg){
      NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
      Notification notification = new Notification(android.R.drawable.sym_action_email, msg, System.currentTimeMillis());
  
      // The PendingIntent will launch activity if the user selects this notification
      Intent intent = new Intent(this, MainActivity.class)
      intent.putExtra("yourpackage.notifyId", id);
      PendingIntent contentIntent = PendingIntent.getActivity(this, 1, intent, 0);
  
      notification.setLatestEventInfo(this, "title", msg, contentIntent);
  
      manager.notify(id, notification);
  }
  </code></pre>
  
  <p>When the notification is clicked, I want to call a method, preferrably with access to the id of the notification.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Tim</p>
  
  <p>(EDIT: I updated my code after reading the first answer, but I still don't know how to listen for the intent)</p>