通知はロック画面に表示されません

Ulrich_Peters:

私は、ロック画面に通知を表示したいが、私は仕事にそれを得ることができないんです。

これは私が持っているというのが私のコードです。

                  .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);
      } 

通知はロック画面に表示されていません。アプリの設定は、ロック画面に通知を表示することができます。

何かアドバイス?

memresubasi:

builder.setOngoing(true)

ロック画面に表示される通知を行います。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=236999&siteId=1