title: Android Notification intent to clear it self
body: <p>I have read many examples of how to create notification messages.
  What i wanted to achieve, is because the notification will be executed by a widget, i would like
  the notification intent when clicked to clear it self when the user clicks on it.I do not have an activity to return to.
  The notification for my purposes will just plainly notify, nothing else.
  So what would be the code of an intent that just clear/cancel itself.
  The code below is an activity launched by a button(button code not included) the notification will be fired up by a background service.</p>
  
  <pre><code>CharSequence title = "Hello";
  CharSequence message = "Hello, Android!";
  final NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  final Notification notification = new Notification(R.drawable.icon,"A New Message!",System.currentTimeMillis());
  
  notification.defaults=Notification.FLAG_ONLY_ALERT_ONCE+Notification.FLAG_AUTO_CANCEL;
  Intent notificationIntent = new Intent(this, AndroidNotifications.class);
  PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,notificationIntent, 0);
  
  notification.setLatestEventInfo(AndroidNotifications.this, title,message, pendingIntent);
  notificationManager.notify(NOTIFICATION_ID, notification);
  </code></pre>
  
  <p>Thanks</p>