Java 将图标按钮添加到通知的右侧
我认为在android中显示动作的通常方式有点难以点击和找到。用户需要执行两个操作(滑动通知,然后单击该操作) 因此,我想在通知的右侧添加一个按钮,以便更容易点击Java 将图标按钮添加到通知的右侧,java,android,push-notification,notifications,kotlin,Java,Android,Push Notification,Notifications,Kotlin,我认为在android中显示动作的通常方式有点难以点击和找到。用户需要执行两个操作(滑动通知,然后单击该操作) 因此,我想在通知的右侧添加一个按钮,以便更容易点击 我发现解决这个问题的唯一方法是使用MediaStyle,但它有一些问题: 它创建了一个通知,但它全是黑色的 我不希望它像这样扩展 我想添加常规操作(cog图标,配置屏幕的快捷方式) 到目前为止,我得到的代码是: Notification notification = new NotificationCompat.Builder(
我发现解决这个问题的唯一方法是使用
MediaStyle
,但它有一些问题:
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher_round)
.setContentTitle("WorkTime")
.setContentText("Estimativa de saída: 19:00h")
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setOngoing(true)
.addAction(R.drawable.ic_fingerprint_black_24dp, "bater ponto", null)
.setStyle(
new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setShowActionsInCompactView(0)
)
.build();
notificationManager.notify(1, notification);
我需要通知你吗
PS:您可能会注意到,smallIcon不起作用。一些提示会很受欢迎,但我知道这将是另一个问题,我想我可以自己找到解决方案。您需要在通知上设置一个大图标我相信largeIcon仅在Android N+上可用。我的手机仍然是安卓M。而且,我不认为这个大图标能起作用