Notificaciones no aparece en la pantalla de bloqueo

Ulrich_Peters:

Quiero mostrar notificaciones en la pantalla de bloqueo, pero soy incapaz de conseguir que funcione.

Este es mi código que tengo;

                  .setSmallIcon(R.drawable.deleteaccounticon)
                  .setContentTitle("My notification")
                  .setContentText("Much longer text that cannot fit one line...")
                  .setStyle(new NotificationCompat.BigTextStyle()
                          .bigText("Much longer text that cannot fit one line..."))
                  .setPriority(NotificationCompat.PRIORITY_HIGH);

          builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
              CharSequence name = "channel1";
              String description = "test";
              int importance = NotificationManager.IMPORTANCE_HIGH;
              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 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
              notificationManager.createNotificationChannel(channel);
              notificationManager.notify(1,builder.build());
              channel.setLockscreenVisibility(VISIBILITY_PUBLIC);
      } 

Las notificaciones no se muestra en la pantalla de bloqueo. Los ajustes para la aplicación permite mostrar notificaciones en la pantalla de bloqueo.

¿Algún consejo?

memresubasi:

builder.setOngoing(true)

hace que la notificación se muestra en la pantalla de bloqueo.

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=237002&siteId=1
Recomendado
Clasificación