gpt4 book ai didi

android - 使用我的 Android 应用程序注册 FileExtension

转载 作者:行者123 更新时间:2023-11-30 02:56:00 24 4
gpt4 key购买 nike

我有一个只包含“abcdefg”这样的文本的文件,它可以从网上下载或从本地存储卡打开。我的想法是给这个文件一个独有的扩展名,比如 .myfile 并在我的应用程序中注册“.myfile”。我在谷歌上找到了一些解决方案,但没有一个对我有帮助。似乎文件扩展名无关紧要,只有内容类型才重要。但是,我想我必须在我的 android list 中使用 mimeType 和 pathPattern...[...] 注册一个 intent-filter。但我到底需要做什么?

    <intent-filter>

<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="application/myfile"
android:host="*"
android:pathPattern=".*\\.myfile"/>
</intent-filter>

这对我不起作用:(

最佳答案

  <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.myfile"
android:scheme="file" />

这行得通!

关于android - 使用我的 Android 应用程序注册 FileExtension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23251435/

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