首页 > 解决方案 > 关闭应用程序时如何隐藏推送通知的标题?

问题描述

在 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 中的配置是正确的。那么,我怎样才能一直显示没有标题的推送通知。 应用关闭 应用打开

标签: androidpush-notification

解决方案


推荐阅读