Desactivación de la eliminación de notificaciones de Android

¿Es posible desactivar la función de eliminación de borrado de una notificación de android desde la lista de notificaciones de android. Por favor, ayúdame.

Gracias por adelantado.

Puede marcar su Notificación como una notificación "en curso".

-> Notification.Builder setOngoing

Prueba este código

builder.setOngoing(true); // Cant cancel your notification (except notificationManager.cancel(); ) 

Por encima del código en Notifcation Builder.

 public void DisplayNotification() { // Use NotificationCompat.Builder to set up our notification. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); //icon appears in device notification bar and right hand corner of notification builder.setSmallIcon(R.drawable.ic_stat_notification); // This intent is fired when notification is clicked Intent tapIntent = new Intent(CurrentActivity.this, SecondActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, tapIntent, 0); // Set the intent that will fire when the user taps the notification. builder.setContentIntent(pendingIntent); builder.setOngoing(true); // Cant cancel your notification (except NotificationManger.cancel(); ) // Content title, which appears in large type at the top of the notification builder.setContentTitle("Notifications Title"); // Content text, which appears in smaller text below the title builder.setContentText("Your notification content here."); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Will display the notification in the notification bar notificationManager.notify(NOTIFICATION_ID, builder.build()); } 

Cancelar notificación

 public void cancelNotification() { mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(NOTIFICATION_ID); // Notification ID to cancel } 

Codificación feliz

  • ¿Cómo enviar notificaciones a usuarios específicos con FCM?
  • ¿Qué significa gcm.notification.e = 1, en la carga de notificación push en Android?
  • Iniciar servicio desde la notificación
  • Uid ... no tiene android.permission.UPDATE_APP_OPS_STATS
  • Android NotificationManager que me da "ningún icono pequeño válido" error
  • Iluminar la pantalla cuando la notificación recibió android
  • Android - Ventana de diálogo Prompt cuando toque en Notificación
  • Cómo deshabilitar la barra de estado o barra de notificación, pero no deshabilitar la barra de título en android?
  • Ejecutar código cuando se cancela la notificación de Android
  • Java.lang.NoSuchMethodError: android.app.Notification $ Builder.build
  • Notificación de barra de estado de Android: haz que no se pueda borrar y vuelve a la aplicación (no inicia una nueva instancia)
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.