Show android notification action buttons expanded by default
Asked Answered
B

2

9

Is there a way to show action buttons in notification expanded by default? I use ongoing notification to control traning process in my app. I want controling buttons such as "Stop" and "Pause" to be visible right after notification appeared in the notification area.

Collapsed buttons by default

Want the buttons to be expanded

Branscum answered 16/11, 2017 at 8:11 Comment(5)
Please go through to https://mcmap.net/q/361927/-is-possible-set-expanded-notification-as-default-in-big-text-notificationsAlsatian
@LakshayJuneja thanks for quick reply. But I do not use BigTextStyle, I just want my action buttons was visible. Do those rules apply for buttons as well?Branscum
@ Oleksandr Albul... yes because you can only set priority to your notifications as setPriority(NotificationCompat.PRIORITY_HIGH) or any other. To show notification as you expected is OS dependent.Alsatian
@LakshayJuneja I've already done setPriority(NotificationCompat.PRIORITY_HIGH), but notification appears in the top and still has buttons collapsed.Branscum
sorry for the such delay, as I have already mentioned above you couldn't force OS to show notification as expanded.Alsatian
O
9

You can't expand notification. The only solution is, set Priority Max, then the top of the notification list where it would be expanded. And it depends on the device as well.

mBuilder.setPriority(Notification.PRIORITY_HIGH)
Ouzo answered 25/7, 2018 at 8:37 Comment(4)
It seems accepted answer for this moment. And the only way to show buttons without expanding is to implement your custom layout for the notification.Branscum
I wanted inverse. I wanted to collapse notification by default so I changed it to NotificationManager.IMPORTANCE_MIN and It worked.Delois
priority didn't work for Samsung S10, still collapsed by default, only for Pixel 4Jarboe
Make sure you also set the priority for any NotificationChannel you create!Nakamura
D
0

I am working on project . There is same requirement come . I searched online . And i found a solution , i just add few line in my notification it work.

notification.priority = NotificationCompat.PRIORITY_MAX
notification.setStyle(NotificationCompat.BigTextStyle())
Disbranch answered 23/10, 2023 at 6:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.