android - 关闭应用程序时如何隐藏推送通知的标题?
问题描述
在 Android 中,当设备收到推送通知(7.0 以上版本)时,我配置为显示 2 行:应用程序名称、内容消息,当应用程序打开时它工作正常。
String channelId = context.getString(R.string.default_notification_channel_id);
int statusBarIcon = R.drawable.ic_app_logo;
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId);
notificationBuilder
.setAutoCancel(true)
.setShowWhen(true)
.setSound(soundUri)
.setContentTitle(null)
.setContentText(message)
.setContentIntent(pendingIntent);
但是我关闭了应用程序,当收到推送通知时,通知显示为 3 行:应用程序名称、标题(也是应用程序名称)和内容消息。AndroidManifest 中的配置是正确的。那么,我怎样才能一直显示没有标题的推送通知。 应用关闭 应用打开
解决方案
推荐阅读
- rust - 如何实现定义新公共类型并返回该类型实例的宏?
- python - 如何将多个表解析为一个数据框?
- batch-file - 任务调度程序说任务正在运行,但它不是
- python - Excel表格的多线程Python代码
- javascript - 创建对象属性的函数?
- bash - 使用for循环复制一系列文件失败,找不到问题
- c++ - 从文件读取时如何访问以前的字符串?
- python - 如何在可见时保持单击元素 - SELENIUM
- swiftui - SwiftUI ObservableObject 和 @ObservedObject 不保持状态
- amazon-web-services - AWS 绿草错误不兼容 GccVersion