gpt4 book ai didi

android - 注册 Activity 以打开具有特定扩展名的任何文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:20 27 4
gpt4 key购买 nike

我一直在开发一个应用程序,该应用程序设置为打开具有特定扩展名的文件。它有时可以与 Gmail 一起使用(有些文件打开,有些则不能),而且我可以从文件资源管理器打开文件。

但是,我无法从手机上的电子邮件应用程序打开文件,正如我所说,有些文件无法通过我的应用程序从 Gmail 应用程序打开,而有些则可以!

这是我的代码。

             <intent-filter > <!-- Solution from @richardlegget on this question http://stackoverflow.com/questions/8148629/intent-filter-to-download-attachment-from-gmail-apps-on-android -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/octet-stream" android:pathPattern=".*\\.myextension" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" android:scheme="file" android:host="*" android:pathPattern=".*\\.myextension" />
</intent-filter>

我的问题

是否有一套完整的 Intent 过滤器,可以从 Android 设备上的任何位置向包含所需文件扩展名的任何文件注册特定 Activity ?

最佳答案

当您可以使用单个标签时,不确定为什么要使用单独的 intent-filters。

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

可能存在权限问题。 I.E 如果您的 Activity 设置为在单独的任务中打开,则无法访问其他应用程序创建/拥有的文件。您必须设置 Intent 标志,使其在同一应用程序中打开。

关于android - 注册 Activity 以打开具有特定扩展名的任何文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21529745/

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