android - 如何避免在 Android Oreo 及更高版本上出现抬头通知?

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

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

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

我只想在通知栏中显示。

有人可以建议,我必须设置什么属性吗?

最佳答案

确保您的 Activity 不是全屏。

将通知设置为低优先级

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

对您的通知 channel 重要性较低

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

关于android - 如何避免在 Android Oreo 及更高版本上出现抬头通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53113553/

相关文章:

android - 如何获得 X 按钮以停止 Android P 上的媒体样式通知?

android - 如何从另一个类显示警报对话框并在当前 Activity 中处理它(Android)

android - 蓝牙设备未在 android oreo 中列出

安卓 O | API 级别 26 或 27

java - 如何在 EditText 上设置默认值后显示 EditText 的提示? (安卓Java)

java - 如何从 okhttp3.ResponseBody 获取 url?

java - 如何使用 SimpleDateFormat.parse() 将 Calendar.toString() 转换为日期?

安卓磨损 : launching an activty in the handheld on clicking notification action button in wear

android - FragmentManager IndexOutOfBoundsException 无法恢复 Activity 崩溃

android - React Native 多行 ReturnKeyType 错误