title: Can't get a notification to show
body: <p>Can't get the status bar notifications to work... I followed <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html" rel="nofollow">this</a> guide, and created the following code in an <code>AsyncTask</code>, it's called from the <code>doInBackground()</code> method:</p>
  
  <pre><code>private void newNotification(int count) {
      NotificationCompat.Builder builder = new NotificationCompat.Builder(handler.getContext());
      builder.setContentTitle("New Notification");
      builder.setContentText("Testing notification");
      builder.setNumber(count);
  
      // Creates an explicit intent for an Activity in your app
      Intent intent = new Intent(handler.getContext(), MainActivity.class);
  
      // The stack builder object will contain an artificial back stack for the
      // started Activity.
      // This ensures that navigating backward from the Activity leads out of
      // your application to the Home screen.
      TaskStackBuilder stackBuilder = TaskStackBuilder.create(handler.getContext());
  
      // Adds the back stack for the Intent (but not the Intent itself)
      stackBuilder.addParentStack(MainActivity.class);
  
      // Adds the Intent that starts the Activity to the top of the stack
      stackBuilder.addNextIntent(intent);
      PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
      builder.setContentIntent(pendingIntent);
      NotificationManager notificationManager = (NotificationManager) handler.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
      notificationManager.notify(0, builder.build());
  }
  </code></pre>
  
  <p><code>handler</code> is a reference to <code>MainActivity</code>, using an interface that implements <code>getContext()</code>, which returns <code>this.getContext()</code> of the <code>MainActivity</code></p>
  
  <p>For some reason when I call it with the parameter 1, nothing happens. </p>
  
  <pre><code>@Override
  protected String[] doInBackground(String... empty) {
      newNotification(1);
      return null;
  }   
  </code></pre>
  
  <p>Debug shows that all the lines of the code are running, but no notifications appear. I didn't find any mention of a special permission, or that it needs to run from a UI thread anywhere. I assume it doesn't since background services are meant to notify... like when a message arrives.</p>
  
  <p>Any ideas what I did wrong?</p>