title: create an "ongoing" notification android
body: <p>I can't find a way to create an "ongoing" notification - I actually am not sure this kind of notification is even called that way - like in the photo below :</p>
  
  <p><a href="https://i.stack.imgur.com/tttMG.jpg" rel="nofollow noreferrer">Grey Notification Messenger</a></p>
  
  <p>How could I achieve that with my notification (Pinger)? My notification is created for a foreground service so I don't no if what I'm asking is possible.</p>
  
  <p>Thanks for your help.</p>
  
  <p>Edit : The answers that you can find herre (<a href="https://stackoverflow.com/questions/5693997/android-how-to-create-an-ongoing-notification">Android: How to create an &quot;Ongoing&quot; notification?</a>) did not solve my problem. This question is not a duplicate.</p>
  
  <p>My code :</p>
  
  <pre><code>Intent showTaskIntent = new Intent(getApplicationContext(), BackingService.class);
      showTaskIntent.setAction(Intent.ACTION_MAIN);
      showTaskIntent.addCategory(Intent.CATEGORY_LAUNCHER);
      showTaskIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
      Intent detailsIntent = new Intent(BackingService.this, DetailsActivity.class);
      detailsIntent.putExtra("EXTRA_DETAILS_ID", 42);
      PendingIntent contentIntent = PendingIntent.getActivity(
              getApplicationContext(),
              0,
              showTaskIntent,
              PendingIntent.FLAG_UPDATE_CURRENT);
      PendingIntent replyPendingIntent = null;
      if (Build.VERSION.SDK_INT &lt; 24) {
          replyPendingIntent = contentIntent;
      } else {
          replyPendingIntent = PendingIntent.getBroadcast(
                  BackingService.this,
                  0,
                  new Intent(BackingService.this, FromNotifSender.class),
                  PendingIntent.FLAG_UPDATE_CURRENT
          );
      }
      RemoteInput remoteInput = new RemoteInput.Builder(KEY_NOTIFICATION_REPLY)
              .setLabel("Tapez votre message ici")
              .build();
      android.support.v4.app.NotificationCompat.Action replyAction = new android.support.v4.app.NotificationCompat.Action.Builder(
              0, "Envoyer à "+usernamefriend, replyPendingIntent)
              .addRemoteInput(remoteInput)
              .build();
      android.support.v4.app.NotificationCompat.Builder miBuilder = new NotificationCompat.Builder(BackingService.this)
              .setSmallIcon(R.drawable.logo4)
              .setContentTitle(getString(R.string.app_name))
              .setContentText(contentText)
              .setWhen(System.currentTimeMillis())
              .setContentIntent(contentIntent)
              .setAutoCancel(false)
              .setOngoing(true)
              .setColor(getResources().getColor(R.color.colorPrimaryDark));
      if (Build.VERSION.SDK_INT &lt; 24) {
      } else {
          if(usernamefriend.equalsIgnoreCase("un ami")){
  
          }else{
              miBuilder.addAction(replyAction);
          }
  
      }
      Intent resultIntent = new Intent(BackingService.this, SearchActivity.class);
      TaskStackBuilder stackBuilder = TaskStackBuilder.create(BackingService.this);
      stackBuilder.addParentStack(SearchActivity.class);
      stackBuilder.addNextIntent(resultIntent);
      PendingIntent resultPendingIntent =
              stackBuilder.getPendingIntent(
                      0,
                      PendingIntent.FLAG_UPDATE_CURRENT
              );
      miBuilder.setContentIntent(resultPendingIntent);
      startForeground(002, miBuilder.build());
  </code></pre>
  
  <p>As you can see, .setOngoing(true) doesn't work for me.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>You only have to set the priority of your notification to Notification.PRIORITY_MIN as in the code following : </p>
  
  <pre><code>android.support.v4.app.NotificationCompat.Builder miBuilder = new NotificationCompat.Builder(BackingService.this)
              .setSmallIcon(R.drawable.logo4)
              .setContentTitle(getString(R.string.app_name))
              .setContentText(contentText)
              .setWhen(System.currentTimeMillis())
              .setContentIntent(contentIntent)
              .setAutoCancel(false)
              .setOngoing(true)
              .setColor(getResources().getColor(R.color.colorPrimaryDark))
              .setPriority(Notification.PRIORITY_MIN);
  </code></pre>