Is possible set Expanded Notification as default in Big Text Notifications?
Asked Answered
R

5

47

I followed this Sample Code

In Big Text Notifications section, he said that need expand to see Big text notification form, as image im below :

enter image description here

I wonder that we can not set Expanded Notification as default in Big Text Notifications?

People who know it is can or not,

If can,

Please tell me how to do it,

Thanks,

Richmal answered 28/4, 2014 at 2:39 Comment(3)
You can change it by implementing custom notification, and by setting height as much you wish. I could write example if you want.Zecchino
@DjDexter Please make the answer for people to know. If it really be useful, people and I will vote also.Richmal
Please read this amazing answer : https://mcmap.net/q/369240/-android-notification-buttons-not-showing-upAhead
I
55

The documentation states:

A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture.

So my answer is no, you can't expand it by default.

There is however a trick to push the notification to the top of the list where it would be expanded. Simply set the Priority to Notification.PRIORITY_MAX and chances are that your app's notification will make it to the top.

Innovate answered 28/4, 2014 at 2:44 Comment(9)
Okay, thanks. It looks like Google only allow Gmail application can show this Big Text Style as default if there is only it was shown on Notification bar.Richmal
IMO Gmail doesn't expand its notifications at least not on the devices I just tested (only Nexus devices). BTW you can try to push your notifications to the top of the list so they get expanded. Not 100% reliable but better than nothing (I updated my answer accordingly).Innovate
"the top of the list where it would be expanded" - Yes, you're right. The devices supported from Android 4.1 can show Big Text Style. My Galaxy S3 can be showed it, not only Nexus devices.Richmal
The Automatic app seems to be pre-expanded when you've parked your car.Suffragan
if P_MAX is set, then the notification will be displayed as a heads-up notification. As well, when I tried this, pushbullet, connected via usb, and mobile data limit exceeded notifications were still on top. Do you have a workaround as this doesnt seem to give the desired result.Langsdon
It's no more on site - >>A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture.Decompress
I would warn against pushing your notifications to the top, just so that they are expanded. Your priority level should be based on the UI guidelines - material.google.com/patterns/…. Otherwise, you are very likely to upset your users.Late
My BigText overlaps small. This is not expand on clickUnravel
Regarding Notification.PRIORITY_MAX, This constant was deprecated in API level 26. use NotificationManager#IMPORTANCE_HIGH instead.Ess
U
14
Notification noti = new Notification.Builder()
... // The same notification properties as the others
.setStyle(new Notification.BigPictureStyle().bigPicture(mBitmap))
.build();

You change

.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))

along with the announcement

notification = new NotificationCompat.Builder(context)

Here is an example:

enter image description hereYou can set Code

Intent intent = new Intent(context, ReserveStatusActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
intent = new Intent(String.valueOf(PushActivity.class));
intent.putExtra("message", MESSAGE);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(PushActivity.class);
stackBuilder.addNextIntent(intent);
// PendingIntent pendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

// android.support.v4.app.NotificationCompat.BigTextStyle bigStyle = new     NotificationCompat.BigTextStyle();
// bigStyle.bigText((CharSequence) context);

notification = new NotificationCompat.Builder(context)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(th_title)
    .setContentText(th_alert)
    .setAutoCancel(true)
 // .setStyle(new Notification.BigTextStyle().bigText(th_alert)  ตัวเก่า
 // .setStyle(new NotificationCompat.BigTextStyle().bigText(th_title))
    .setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
    .setContentIntent(pendingIntent)
    .setNumber(++numMessages)
    .build();

notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(1000, notification);
Undertaker answered 24/9, 2015 at 20:36 Comment(1)
My BigText overlaps small. This is not expand on clickUnravel
F
1
notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText("Your Long Text here"))

simply setStyle of your notification builder.

Fabrianna answered 21/2, 2019 at 9:47 Comment(0)
T
0

No need of doing any kind of modification in the any file for showing of multiple lines of Notification while using Push Notification V5, remove the field "style", from the object you are sending. Automatically the Multiple lines of notification will be seen. For more information, upvote the answer, ask your query. I will help you out.

For reference, visit this question

Tricrotic answered 28/11, 2017 at 6:54 Comment(0)
L
0

From this notification code you have got images, and big text or more.

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mBuilder.setSmallIcon(R.drawable.small_logo);
                mBuilder.setColor(Color.parseColor("#D74F4F"));
            } else {
                mBuilder.setSmallIcon(icon);
            }

            mBuilder.setTicker(title).setWhen(when);
            mBuilder.setAutoCancel(true);
            mBuilder.setContentTitle(title);
            mBuilder.setContentIntent(intent);
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
            mBuilder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon));
            mBuilder.setContentText(msg);
            mBuilder.setPriority(Notification.PRIORITY_MAX);
            if (Utils.validateString(banner_path)) {
                mBuilder.setStyle(notiStyle);
            } else {
                mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));
            }

            Notification noti = mBuilder.build();
            notificationManager.notify(0, noti);
Leister answered 28/11, 2017 at 8:50 Comment(3)
What's the part of "notiStyle" ? What is validateString ?Zirconium
NotiStyle is a NotificationCompat.BigPictureStyle and validateString is just check your string value is valid or not.Leister
Can you please put those here too?Zirconium

© 2022 - 2024 — McMap. All rights reserved.