Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 某些设备未显示消息正文,只有标题可见_Android_Android Layout_Push Notification_Android Notifications - Fatal编程技术网

Android 某些设备未显示消息正文,只有标题可见

Android 某些设备未显示消息正文,只有标题可见,android,android-layout,push-notification,android-notifications,Android,Android Layout,Push Notification,Android Notifications,这就是我向用户显示推送通知的方式 Notification notification = new Notification.Builder(getApplicationContext()) .setSmallIcon(R.drawable.ic_launcher) .setAutoCancel(true) .setContentIntent(intent) .setContentTitle("Title") .setStyle(new Notificati

这就是我向用户显示推送通知的方式

Notification notification = new Notification.Builder(getApplicationContext())
    .setSmallIcon(R.drawable.ic_launcher)
    .setAutoCancel(true)
    .setContentIntent(intent)
    .setContentTitle("Title")
    .setStyle(new Notification.BigTextStyle()
    .bigText(msg))
    .setSound(soundUri)
    .build();
notificationManager.notify(0, notification);
这在
三星s5
三星s7
上运行良好。但在三星Note3上,它只显示标题,不显示消息正文。这也可能发生在其他一些设备中

请告诉我这是什么原因。

试试这段代码

NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setAutoCancel(true)
                    .setContentIntent(intent)
                    .setContentTitle("Title")
                    .setStyle(new Notification.BigTextStyle()
                        .bigText(msg))
                    .setSound(soundUri)
                    .setContentText(detail);


    NotificationManager mNotifyMgr =
            (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

    mNotifyMgr.notify(mNotificationId, mBuilder.build());
试试这个代码

NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setAutoCancel(true)
                    .setContentIntent(intent)
                    .setContentTitle("Title")
                    .setStyle(new Notification.BigTextStyle()
                        .bigText(msg))
                    .setSound(soundUri)
                    .setContentText(detail);


    NotificationManager mNotifyMgr =
            (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

    mNotifyMgr.notify(mNotificationId, mBuilder.build());

.setContentText(msg)
添加到您的呼叫链应该可以解决此问题


声明“如果平台不提供丰富的通知样式,[
setStyle(样式样式)
]无效”。我要大胆地说,这就是问题的原因。

向您的呼叫链添加
.setContentText(msg)
,应该可以解决问题


声明“如果平台不提供丰富的通知样式,[
setStyle(样式样式)
]无效”。我要大胆地说,这就是问题的原因。

好的,那么我需要删除bigText()吗?因为我添加了bigText以多行显示文本no:S,正如我所说,无论您在
setStyle
中做什么,都不会对某些设备产生任何影响,我只是假设note3就是其中的一种设备。但在提供丰富通知样式的设备中,
setStyle
将起作用。因此,删除或保留bigText()大概不会影响便笺上的任何内容3@Kirmani88如果它回答了你的问题,请接受这个答案,这样其他看这个问题的人就会知道它是有效的。好的,那么我需要删除bigText()吗?因为我添加了bigText以多行显示文本no:S,正如我所说,无论您在
setStyle
中做什么,都不会对某些设备产生任何影响,我只是假设note3就是其中的一种设备。但在提供丰富通知样式的设备中,
setStyle
将起作用。因此,删除或保留bigText()大概不会影响便笺上的任何内容3@Kirmani88如果它回答了你的问题,请接受这个答案,这样其他看这个问题的人就会知道它是有效的。是的,它确实有帮助。谢谢,这确实有帮助。谢谢