android - 如何调试通知中的智能回复?
问题描述
随着 Android 10 的发布,他们在通知中宣布了一项名为智能回复(已存在于 Gmail/Messages 应用程序中)的新功能。
现在,我的应用中有很多关于通知的代码,我们经常使用它们。出于显而易见的原因,我想测试我们当前的实现是否与那些新系统生成的上下文操作一起正常工作。
有谁知道如何使用 Android 10 模拟器在通知中手动触发智能回复?我一直试图让它们出现一整天(通过在我的应用程序中创建一个虚假通知并更改其内容,例如用地址、电话号码等填充内容)但没有成功。
谢谢 !
解决方案
你的通知有回复动作吗?
val remoteInput = RemoteInput.Builder(BigPictureSocialIntentService.EXTRA_COMMENT)
.setLabel(replyLabel)
.setChoices("Yes","No")// hardcoded responses for Android P
.build()
如果您有硬编码setChoices(listOfReplies)
系统将不会提供智能回复。
//When you build action setAllowGeneratedReplies to true
val replyAction = NotificationCompat.Action.Builder(
R.drawable.ic_reply_white_18dp,
replyLabel,
replyActionPendingIntent)
.addRemoteInput(remoteInput)
.setAllowGeneratedReplies(true)
.build()
// 对于建议的操作,将 setAllowSystemGeneratedContextualActions 设置为 true
.notificationCompatBuilder.setStyle()
.setContentTitle(contentTitle)
.setContentText("Hey lets meet for dinner at xx sretee Rd, New York Postocde")
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(
resources,
R.drawable.ic_person_black_48dp))
.setAllowSystemGeneratedContextualActions(true)
.setSubText(Integer.toString(1))
.addAction(replyAction)
话虽如此,当前的模拟器不提供任何智能回复,我尚未在运行 10 的实际设备上对其进行测试
推荐阅读
- javascript - 仅当模块存在于 node/gulp 中时如何加载它?
- python - tensorflow 创建的 core.xxxxx 文件有哪些?
- flutter - 网页颤动:底部的文字被切断
- c# - 无法在 C# 应用程序中为 SQL 错误抑制 SQL Server 错误消息弹出
- r - 预测自动绘图上的预测间隔级别
- javascript - 从 https://blob JSON url 调用数据并在 Javascript 网页中显示
- python - Python通过水平虚线将图像拆分为多个部分
- r - 为什么我得到向上的生存曲线(累积发病率)?
- java - 如何从 Json 中坚持 @OneToMany 和 @ManyToOne
- javascript - 如何在类组件中使用 useMediaQuery