dev90
dev90

Reputation: 7579

Some Devices are not displaying Message body, only title is visible

This is how i am displaying Push Notification to user.

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);

This is working fine on Samsung s5, Samsung s7. But on samsung Note3 , it only displays title, and does not display message body. This may be occurring in some other devices as well.

Kindly guide me that what can be the reason of this.

Upvotes: 0

Views: 1132

Answers (2)

Mehmet K
Mehmet K

Reputation: 2814

Adding .setContentText(msg) to your call chain should solve the problem.

Android documentation for NotificationCompat states that "If the platform does not provide rich notification styles, [setStyle(Style style)] has no effect". I'm going to take a leap of faith and say that this is the cause of the problem.

Upvotes: 2

hardik9850
hardik9850

Reputation: 1096

Try this code

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());

Upvotes: 1

Related Questions