gpt4 book ai didi

Android:在 native 电子邮件中打开自定义文件附件的问题

转载 作者:行者123 更新时间:2023-11-30 03:50:07 24 4
gpt4 key购买 nike

我有一个扩展名为 .abc 的文件,我试图在我的个人应用程序中读取该文件。我的 list xml 中有以下 Intent 过滤器。

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:scheme="content" />
<data android:mimeType="*" />
<data android:pathPattern=".*\\.abc" />
<data android:host="*" />
</intent-filter>

此过滤器捕获从文件浏览器、第 3 方电子邮件客户端等发送的所有 Intent ,但 native 电子邮件客户端除外。文件浏览器应用程序和 native 电子邮件客户端之间的唯一区别是,文件浏览器的方案是"file",而 native 电子邮件客户端的方案是“内容”。当我在 native 电子邮件客户端的附件中单击扩展名为 .abc 的文件时,它甚至不会下载该文件,也不会触发任何 Intent 。关于问题可能出在哪里的任何建议?

如果我遗漏了任何信息,我很乐意添加到问题中。

最佳答案

这就是问题的解决方案。具有自定义扩展名的文件的 mime 类型是 application/。将以下过滤器添加到 list 文件解决了这个问题。

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="application/abc" />
<data android:host="*" />
</intent-filter>

关于Android:在 native 电子邮件中打开自定义文件附件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14288113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com