没有点击事件的地面服务通知

Forgroundservice notification without click event

我已经创建了 forgroundservice 并显示了通知,当我点击通知时它会打开应用程序设置,我想避免这种情况。 如何禁用 forgroundservice 通知点击事件,因为我的目的是只显示通知任何点击事件不应该发生在这里。

代码:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      
        String CHANNEL_ID = "Channel_1";
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                "Enabled",
                NotificationManager.IMPORTANCE_DEFAULT);

        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);

        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("")
                .setContentText("").build();

        startForeground(1, notification);
    }

我尝试了一些解决方案,但似乎都行不通:

        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("").setContentIntent(pendIntent)
                .setContentText("").build();

将图标添加到通知中,这样点击就不会发生,也不需要 Pending intent。

Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                    .setSmallIcon(R.drawable.logo)
                    .setContentTitle("app is running")
                    .build();