RemoteInput上的AllowedDataTypes是什么?

问题描述 投票:12回答:1

API 26中setAllowDataType上有一个名为RemoteInput.Builder的新函数。这是做什么用的?我尝试了以下方法:

RemoteInput.Builder

[应在val remoteInput = RemoteInput.Builder(KEY_TEXT_REPLY) .setLabel("Image") .setAllowFreeFormInput(false) .setChoices(null) .setAllowDataType("image/*", true) .setAllowDataType("image/png", true) .setAllowDataType("image/jpg", true) .setAllowDataType("image/gif", true) .build() 上将isDataOnly设置为isDataOnly,但是通知在电话上显示如下。单击true按钮没有任何作用。这个是来做什么的?我找不到有关此功能的任何文档,发行说明或教程。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9ua2d4ay5wbmcifQ==” width =“ 300”>


更新

实际发布时,通知中似乎缺少仅数据类型。查看构建器代码,将RemoteInput添加到通知中时,它使用级别24来完全剥离数据类型:Image

原始问题仍然存在。

android notifications android-notifications remote-input
1个回答
0
投票

Actions中显示以下内容:

指定用户是否可以提供任意值。这允许接受非文本值的输入。输入的用法示例需要音频或图像。

因此,我相信如果我正确地阅读了此内容,则函数https://android.googlesource.com/platform/frameworks/support/+/oreo-release/compat/api26/android/support/v4/app/NotificationCompatApi26.java#108将在输入字段中添加允许的类型。因此,如果用户想添加gif,img等,则可以。默认情况下,我不认为用户可以添加此类项目。

© www.soinside.com 2019 - 2024. All rights reserved.