title: Click on Notification doesn't start activity
body: <p>I am creating a notification from a service; the notification is shown, but when I click on it, nothing happens: It was supposed to open an activity.</p>
  
  <p>My code:</p>
  
  <pre><code>NotificationManager notificationManager = (NotificationManager)
  getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification = new Notification(icon, "test", when);
  Intent notificationIntent = new Intent(this, MainActivity.class);
  notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |   Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  PendingIntent intent = PendingIntent.getActivity(this, 0, 
  notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
  
  notification.setLatestEventInfo(this, "title", "message", intent);
  notification.flags |= Notification.FLAG_AUTO_CANCEL;
  notificationManager.notify(0, notification);
  </code></pre>
  
  <p>However if I use pretty much the same code from inside an activity, I can click on the notification, and my activity is shown. What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong>
  It turns out that there was nothing wrong with this code, there was a different issue:
  When my service finished, it created the notification with the code above. However, the service also broadcasted that it was finished, and the receiver created another notification, which used a different code to create the notification (with no PendingIntents, so no defined action when the notification is clicked), and that notification must have placed itself instead of the original, correct one.</p>