Android 通知不显示超过 3 个操作 [英] Android notification not showing more than 3 actions

查看:29
本文介绍了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);

推荐答案

您最多只能显示 Notification.Builder addAction(Notification.Action action)也是

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆