title: Android: Ongoing Notification disappears when pressing on a custom button within remoteView
body: <p>Trying to figure out why my onGoing notification disappears when the user presses on the pause button.  I am trying to implement a media player controls scheme similar to that of the Spotify ongoing notification. I am modifying Androids Sample project "RandomMusicPlayer". I have tried setting setAutoCancel to false.</p>
  
  <p>Related code listed below:</p>
  
  <pre><code>/** Updates the notification. */
  @SuppressWarnings("deprecation")
  private void updateNotification(String text, String artist, boolean showticker) {
      Notification notification = buildNotification(text, artist, showticker);
      if(notification!=null){
          mNotificationManager.notify(NOTIFICATION_ID, notification);
      }
  }
  
  /**
   * Configures service as a foreground service. A foreground service is a service that's doing
   * something the user is actively aware of (such as playing music), and must appear to the
   * user as a notification. That's why we create the notification here.
   */
  @SuppressWarnings("deprecation")
  private void setUpAsForeground(String text, String artist, boolean showticker) {
      Notification notification = buildNotification(text, artist, showticker);
      if(notification != null){
          startForeground(NOTIFICATION_ID, notification);
      }
  }
  
  /**
   * Called when we want to build our notification
   */
  private Notification buildNotification(String title, String artist, boolean showticker){
      PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
              new Intent(getApplicationContext(), HomeActivity.class).setAction(ACTION_OPEN_STREAM_FRAG),
              PendingIntent.FLAG_UPDATE_CURRENT);
  
      PendingIntent pendingStopIntent = PendingIntent.getService(this, 118, new Intent(MusicService.ACTION_STOP), PendingIntent.FLAG_NO_CREATE);
      PendingIntent pendingPauseIntent = PendingIntent.getService(this, 119, new Intent(MusicService.ACTION_PAUSE), PendingIntent.FLAG_NO_CREATE);
      PendingIntent pendingPlayIntent = PendingIntent.getService(this, 120, new Intent(MusicService.ACTION_PLAY), PendingIntent.FLAG_NO_CREATE);
  
      RemoteViews mNotificationView = new RemoteViews(getPackageName(),
              R.layout.player_notification_view);
  
      Notification mNotification = null;
  
      int currentapiVersion = android.os.Build.VERSION.SDK_INT;
  
      NotificationCompat.Builder builder = new NotificationCompat.Builder(
              this);
      mNotificationView.setImageViewResource(R.id.imageNotification, R.drawable.ic_launcher );
      mNotificationView.setTextViewText(R.id.titleNotification, title);
      mNotificationView.setTextColor(R.id.titleNotification, Color.WHITE);
      mNotificationView.setTextViewText(R.id.textNotification, artist);
  
  
      if(mState == State.Playing){
          mNotificationView.setImageViewResource(R.id.control_one_button_notification, R.drawable.ic_action_playback_pause);
          mNotificationView.setImageViewResource(R.id.control_two_button_notification, R.drawable.ic_action_playback_stop);
          mNotificationView.setOnClickPendingIntent(R.id.control_one_button_notification, pendingPauseIntent);
          mNotificationView.setOnClickPendingIntent(R.id.control_two_button_notification, pendingStopIntent);
      }else if(mState == State.Paused){
          mNotificationView.setImageViewResource(R.id.control_one_button_notification, R.drawable.ic_action_playback_play);
          mNotificationView.setImageViewResource(R.id.control_two_button_notification, R.drawable.ic_action_playback_stop);
          mNotificationView.setOnClickPendingIntent(R.id.control_one_button_notification, pendingPlayIntent);
          mNotificationView.setOnClickPendingIntent(R.id.control_two_button_notification, pendingStopIntent);
      }
  
      builder.setContentIntent(pi).setSmallIcon(R.drawable.ic_launcher);
      if(showticker){
          builder.setTicker(title);
      }else{
          builder.setTicker(null);
      }
      builder.setAutoCancel(false).setContent(mNotificationView).setOngoing(true);
      mNotification = builder.build();
  
      return mNotification;
  }
  </code></pre>