我有一个只包含“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/