gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 14:44:38 25 4
gpt4 key购买 nike

我正在尝试像这样自定义 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com