Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RemoteInput上的AllowedDataType是什么?_Android_Notifications_Android Notifications_Remote Input - Fatal编程技术网

Android RemoteInput上的AllowedDataType是什么?

Android RemoteInput上的AllowedDataType是什么?,android,notifications,android-notifications,remote-input,Android,Notifications,Android Notifications,Remote Input,API 26中有一个名为setAllowDataType的新函数。这是用来干什么的?我尝试了以下方法: val remoteInput = RemoteInput.Builder(KEY_TEXT_REPLY) .setLabel("Image") .setAllowFreeFormInput(false) .setChoices(null) .setAllowDataType("image/*",

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

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()
RemoteInput
上,应将其设置为
true
,但手机上显示的通知如下所示。单击
图像
按钮不会执行任何操作。这是干什么用的?我找不到有关此函数的任何文档、发行说明或教程


更新 在实际发布通知时,通知中似乎缺少仅数据类型。查看生成器代码,在向通知中添加
操作时,它使用级别24将数据类型完全剥离:

最初的问题仍然存在。

来自《科学》杂志,它说:

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()
指定用户是否可以提供任意值。这允许 接受非文本值的输入。使用示例是一个输入 需要音频或图像的


因此,我相信如果我读对了,函数
setAllowDataType
将向输入字段添加允许的类型。因此,如果用户想要添加GIF、IMG等。。。他们可以。默认情况下,我不相信用户可以添加这些类型的项目

有趣的是,在
notificationcompatiapi21
null
中,当
allowedatatypes
应该是。请参阅实现。看起来像是一种向
RemoteInput
粘贴或删除某些内容的方法……我看不出Android 8.0源代码中使用了哪些内容,除了自引用内容(例如,确认
setAllowDataType()
正确填充
RemoteInput
的测试)。看起来,
addDataResultToIntent()
是对应的,提供了作为结果的一部分传递的
Uri
值。。。但我找不到在其他类似的自我参照的东西中使用的地方。也许这是一个意外泄漏到Android 8.0 SDK中的部分实现,并将在下一次主要的Android更新中得到充实。。。仍然不知道数据类型是什么;似乎只能通过用户输入或选择来获取字符串文本。