android - Action 按钮在 Android 通知中不可见

标签 android android-notifications

我正在尝试像这样自定义 android 通知。

enter image description here

Above API23 一切正常。对于以下 API23,操作按钮不可见。我没有发现我的代码有什么问题。

这是我针对以下 API23 的示例代码:

RemoteViews expandedView = createMultiRemoteViews(context,
                R.layout.notification_multiview_b23, icon, "Custom notification", "This is a custom layout", leftImage, rightImage, "09:10", "16:23");

expandedView.setOnClickPendingIntent(R.id.left_image, leftImageIntent);
expandedView.setOnClickPendingIntent(R.id.right_image, rightImageIntent);

NotificationCompat.Action addToWatchListAction = new NotificationCompat.Action.Builder(R.drawable.ic_bookmark_border_black_24dp,
                LABEL_ADD_TO_WATCH_LIST, addToWatchList).build();

NotificationCompat.Builder builder = createNotificationBuider(context, "Custom notification", "This is a custom layout", icon);
builder.addAction(addToWatchListAction);
builder.setCustomBigContentView(expandedView);

showNotification(context, builder.build(), MULTI_NOTI_ID);

最佳答案

通知操作在 API 24 以下不可用。这可能是兼容性问题。要支持向后兼容性,请使用支持库的 NotificationComapt 类。 这是 a link到官方文件和a link链接到支持库类。

关于android - Action 按钮在 Android 通知中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41952369/

相关文章:

java - 基本数据类型 准确性

android - 删除项目后,RecyclerView 不更新

android - Appcelerator [错误] : Invalid "--device-id" value

Android:是否可以通过编程方式删除系统管理的通知?

android - PendingIntent 不适用于 Android O

android - 如何在 Spotify 和 Google Music 等后台播放音乐时关闭通知

java - ADT 更新后出现 NoClassDefFound 错误

android - 进度搜索栏通知未显示在 DownloadManager android 中

java - 如何借助NotificationListnerService在通知中按下“标记为已读”按钮?

java - 如何在录音时为语音留言设置定时器(与 WhatsApp 语音留言录音功能相同)?