title: How to legally prevent notification get removed in Android
body: <p>I'm working on an app and want to provide a shortcut of a function to user by adding a ongoing notification. It's a little bit like some of dictionary app doing that they provide a shortcut as notification for quick search.<br />
  The problem is even I have setOngoing(true) and setAutoCancel(false), it's still get removed once the app is closed from multitasking pane
  The code I was using as below .</p>
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {
              CharSequence name = &quot;C1&quot;;
              String description = &quot;C1 is C1&quot;;
              int importance = NotificationManager.IMPORTANCE_DEFAULT;
              NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
              channel.setDescription(description);
              // Register the channel with the system; you can't change the importance
              // or other notification behaviors after this
              NotificationManager notificationManager = getSystemService(NotificationManager.class);
              notificationManager.createNotificationChannel(channel);
          }
  
  
  
  NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
                  .setSmallIcon(R.mipmap.ic_launcher)
                  .setContentTitle(&quot;XXXX&quot;)
                  .setContentText(&quot;XXXXXXXX&quot;)
                  .setPriority(NotificationCompat.PRIORITY_MAX)
                  .setContentIntent(pendingIntent)
                  .setOngoing(true) 
                  .setAutoCancel(false);
          NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainActivity.this);
  
          // notificationId is a unique int for each notification that you must define
          notificationManager.notify(NOTIFICATION_ID_2, builder.build());
  </code></pre>