Android通知显示的动作不超过3 [英] Android notification not showing more than 3 actions
本文介绍了Android通知显示的动作不超过3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示一个包含5个动作的通知,但它只能显示3个动作.这是我用来显示它的代码
I want to display a notification with 5 actions, but it ony displays 3 of them. This is the code I'm using for displaying it
Notification notification =
new android.support.v7.app.NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!")
.addAction(new NotificationCompat.Action.Builder(R.drawable.action1, null, pendingIntent1).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action2, null, pendingIntent2).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action3, null, pendingIntent3).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action4, null, pendingIntent4).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action5, null, pendingIntent5).build())
.setAutoCancel(false)
.build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(MEETING_NOTIFICATION_ID, notification);
推荐答案
you can only show max 3 actions as mentioned in the Notification.Builder addAction (Notification.Action action)
too
展开后的通知最多可以显示3个操作,从 按添加顺序从左到右.
A notification in its expanded form can display up to 3 actions, from left to right in the order they were added.
或者,您创建自定义 RemoteViews
并使用 setCustomContentView
Alternatively you create custom RemoteViews
and use setCustomContentView
参考
这篇关于Android通知显示的动作不超过3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文