【问题标题】:How to avoid Heads-up notification on android Oreo and above?如何避免 Android Oreo 及更高版本上的提醒通知?
【发布时间】:2018-11-02 06:20:39
【问题描述】:

我想在后台显示通知。表示,当用户打开通知屏幕时。

但它出现在我的应用屏幕顶部。我不想显示在我的应用程序的顶部。

我只想在通知栏中显示。

有人可以建议,我必须设置的属性是什么。

【问题讨论】:

    标签: android android-notifications android-8.0-oreo android-notification-bar


    【解决方案1】:

    确保您的活动不是全屏。

    将通知设置为低优先级

    NotificationCompat.Builder mBuilder.setContentTitle(fileName)
                    .setContentText("Notification")
                    .setSmallIcon(R.drawable.icon)
                    .setPriority(NotificationCompat.PRIORITY_LOW)
                    .setAutoCancel(true)
                    .setContentIntent(pendingIntent);
    

    对您的通知渠道的重要性较低

    NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, IMPORTANCE_LOW);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      • 2019-06-28
      • 2021-11-17
      • 1970-01-01
      • 1970-01-01
      • 2020-03-09
      • 1970-01-01
      相关资源
      最近更新 更多