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

Oleksandr Albul
  • 1,611
  • 1
  • 23
  • 31
  • Please go through to [https://stackoverflow.com/a/23331716/5308778](https://stackoverflow.com/a/23331716/5308778) – yashkal Nov 16 '17 at 08:20
  • @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? – Oleksandr Albul Nov 16 '17 at 08:31
  • @ 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. – yashkal Nov 16 '17 at 10:15
  • @LakshayJuneja I've already done setPriority(NotificationCompat.PRIORITY_HIGH), but notification appears in the top and still has buttons collapsed. – Oleksandr Albul Nov 16 '17 at 14:46
  • 1
    sorry for the such delay, as I have already mentioned above you couldn't force OS to show notification as expanded. – yashkal Nov 20 '17 at 05:02

1 Answers1

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)
Anjal Saneen
  • 3,109
  • 23
  • 38
  • 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. – Oleksandr Albul Oct 31 '18 at 10:18
  • I wanted inverse. I wanted to collapse notification by default so I changed it to `NotificationManager.IMPORTANCE_MIN` and It worked. – Rumit Patel Apr 19 '19 at 06:30
  • priority didn't work for Samsung S10, still collapsed by default, only for Pixel 4 – user924 Dec 10 '20 at 14:41
  • Make sure you also set the priority for any NotificationChannel you create! – Jules Jun 20 '23 at 15:22