Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通知未显示在锁定屏幕上_Java_Android_Android Notifications_Lockscreen - Fatal编程技术网

Java 通知未显示在锁定屏幕上

Java 通知未显示在锁定屏幕上,java,android,android-notifications,lockscreen,Java,Android,Android Notifications,Lockscreen,我想在锁屏上显示通知,但无法使其工作 这是我的代码,我有 .setSmallIcon(R.drawable.deleteaccounticon) .setContentTitle("My notification") .setContentText("Much longer text that cannot fit one line...") .setS

我想在锁屏上显示通知,但无法使其工作

这是我的代码,我有

                  .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);
      } 
通知未显示在锁定屏幕上。应用程序的设置允许在锁定屏幕上显示通知

有什么建议吗?

builder.setContinuous(true)


使通知显示在锁屏上。

是否在设置中的锁屏启用中显示通知???