我想在后台显示通知。意思是,当用户打开通知屏幕时。
但它出现在我的应用程序屏幕的顶部。我不想显示在我的应用程序的顶部。
我只想在通知栏中显示。
有人可以建议,我必须设置什么属性吗?
最佳答案
确保您的 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/