私は新しいことがわかりましたChannelNotification
アプローチは古いロジックに取って代わるものではなく、通知のコントロールのレイヤーをもう1つ追加します。 は、だから今、私たちは2つのシナリオを持って、スクリーンショットを参照してください。
![enter image description here](https://i.stack.imgur.com/RqmAA.png)
あなたは通知が有効になっている場合に定義することができます
NotificationManagerCompat.from(context).areNotificationsEnabled();
あなたの通知がユーザーに表示されている場合は、定義することができます。
を NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel =
notificationManager.getNotificationChannel(channelId);
int importance = notificationChannel.getImportance();
重要度がNotificationManager.IMPORTANCE_NONE
の場合、通知は表示されませんが、通知があるので、フォアグラウンドサービスで使用でき、通知を却下する必要があります。重要度がNotificationManager.IMPORTANCE_MIN
以上の場合は通知が表示されます。
通知チャネルの[重要度](https://developer.android.com/reference/android/app/NotificationChannel.html#getImportance())が[IMPORTANCE_NONE](https://developer.android.com/reference)になることがあります/android/app/NotificationManager.html#IMPORTANCE_NONE)?私は確信していない、ちょうど仮定しています。 – azizbekian
@azizbekian仮定してくれてありがとう、それはあなたが正しいことに変わります。 –