api 23中弃用了Android通知.addAction [英] Android notification .addAction deprecated in api 23

查看:493
本文介绍了api 23中弃用了Android通知.addAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于不推荐使用addAction(int icon, CharSequence title, PendingIntent intent),因此向API 23中的通知添加操作的正确方法是什么?找不到任何示例,谢谢.

What is the proper way to add an action to the notification in API 23 since addAction(int icon, CharSequence title, PendingIntent intent) is deprecated ? Couldn't find any example, thank you.

我的旧动作:.addAction(R.drawable.ic_prev, "Previous", prevPendingIntent)

推荐答案

而不是这个:

addAction(int图标,CharSequence标题,PendingIntent意图)

此方法已在API级别23中弃用.

使用:

addAction( Notification.Action操作)

一切都在开发人员文档中!

It's all in the developer docs!

所以要使用这个:

首先使用 NotificationCompat构建动作. Action.Builder

NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_prev, "Previous", prevPendingIntent).build();

注意:使用 NotificationCompat.Action

然后将其添加到您的通知中

And than add it to your notification:

yournotification.addAction(action);

这篇关于api 23中弃用了Android通知.addAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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