Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification text is too long and is not showing full text

I'm developing an application for android 2.3.3. I am showing a notification but the text of this notification is too long and its not showing the full text and its being cut so how can I show my full text in my notification?

Here's the code:

String message = "Tonights Taraweeh consists of Alif Lam Mim and the first quarter of Sayaqul. The Surahs covered are Al-Fatiha(The Opening),and the first two-thirds of Al-Baqara(The Cow).";
Notification notification = new Notification();
notification.setLatestEventInfo(context, title, message, contentIntent);
like image 645
Anas Reza Avatar asked Jun 28 '13 06:06

Anas Reza


2 Answers

Expanded notifications are only available from Android 4.1, read here

Android 2.3.3 uses the old notifications without expansion. You must user a shorter text, cut your text (and show the full text when user click on it) or adapt the text if you are showing the notification in Android 4.1 or older.

like image 61
Pelanes Avatar answered Nov 08 '22 21:11

Pelanes


I short you have to set the BigTextStyle

Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID)
            .setSmallIcon(R.drawable.new_mail)
            .setContentTitle(emailObject.getSenderName())
            .setContentText(emailObject.getSubject())
            .setLargeIcon(emailObject.getSenderAvatar())
            .setStyle(new NotificationCompat.BigTextStyle()
                    .bigText(__BigTextHere___))
            .build();
like image 3
AZ_ Avatar answered Nov 08 '22 22:11

AZ_