Adam Varhegyi
Adam Varhegyi

Reputation: 9894

How to use bigTextStyle in android 4.1 notification?

I tried in many ways to get the long thext styled notification but just cant reach my goal, pls someone help.

I would like to use bigTextStyle in order to get multiline message in my notifs. Here is my code:

mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx, MainActivity.class), 0);


        Notification noti = new Notification.Builder(ctx)
        .setContentTitle("Title")
        .setSmallIcon(R.drawable.ic_launcher)
        .setStyle(new Notification.BigTextStyle().bigText(ctx.getResources().getString(R.string.loremIpsum)))
        .setContentText(ctx.getResources().getString(R.string.loremIpsum))
        .setContentIntent(contentIntent).build();





        mNotificationManager.notify(NOTIFICATION_ID, noti);

I use Android 4.1.2 so the op version is ok. Every notificaion is a simple one-lined message, and i dont see the whole text. Please help me.

E D I T:

Okay i got the long text, but my notif not expanding automatically, i have to swipe down with 2 fingers. How could i expand it by code..!?

Upvotes: 2

Views: 4232

Answers (3)

Diaa Saada
Diaa Saada

Reputation: 1056

even if u set the MAX priority to push your notification to the top or it was the only notification in the notification drawer it wont expand if there is no enough space e.g. to many "Ongoing-notifications" in the "Ongoing"Drawer or your screen is small

and even if it was expanded it wont show more than 8 lines , so not all the notification will shows up

Upvotes: 0

Matthew Lowe
Matthew Lowe

Reputation: 1400

Maybe your notification is getting collapsed because ongoing notifications are eating up the screen space. See my answer here: Android Jelly Bean strange behavior of notifications.

Upvotes: 2

ianhanniballake
ianhanniballake

Reputation: 199880

You have to expand the notification to see the big text - by default only the top notification auto-expands, as described in the Notifications guide.

Upvotes: 2

Related Questions