android - 如何调试通知中的智能回复?

标签 android android-emulator

随着 Android 10 的发布,他们宣布了一项名为 Smart Reply 的新功能(已经存在于 Gmail/Messages 应用程序中)在通知中。

现在,我们在我的应用程序中有很多关于通知的代码,而且我们经常使用它们。出于显而易见的原因,我想测试我们当前的实现是否可以与那些新的 system generated contextual actions 一起正常工作。 .

有谁知道如何使用 Android 10 模拟器在通知中手动触发智能回复?我一整天都在尝试让它们出现(通过在我的应用程序中创建一个虚假通知并更改其内容,例如用地址、电话号码等填充内容)但没有成功。

谢谢!

最佳答案

你的通知有回复 Action 吗?

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 的实际设备上测试它

还要确保在通知设置中启用了智能回复 enter image description here

关于android - 如何调试通知中的智能回复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57995618/

相关文章:

android - 是否可以在图像上绘制/绘画并在 android 中删除它?

android - 如何在 Android 模拟器上捏缩放?

android - 应用程序甚至在启动前就崩溃了

javascript - Android window.orientation 在使用 JavaScript + Phonegap 启动时不正确

java - 如何显示一组随机单词?

android - 帐户每分钟同步一次

java - 无法执行dex : Multiple dex files define Lorg/OpenUDID/OpenUDID_manager$ValueComparator;

android-emulator - 模拟器中没有日历

android - 防止 GridView 进入工具栏下方

Android 模拟器不在屏幕上显示谷歌地图