我有麻烦我的自定义文件扩展名关联到我,我开发Android应用程序。在我的Android清单文件我有以下几点:
I'm having trouble associating my custom file extension to my android application that I am developing. In my android manifest file I have the following:
<data android:scheme="file" android:mimeType="*/*" android:pathPattern="*.*.myFileExt" />
<data android:scheme="content" android:mimeType="*/*" android:pathPattern="*.*.myFileExt" />
这有点儿工作。让我解释。我在我的Gmail(发送一个文件给我自己),它具有正确的扩展名的文件,所以当我从我的手机浏览器下载并点击打开,它正确地打开我的应用程序,但如果我探索的文件路径;该文件的位置,并尝试打开它,我的电话说,没有应用程序可以打开此文件类型。
It kinda works. Let me explain. I have a file in my gmail( sent a file to my self ), which has the proper extension, so when I download it from my phone's browser and click open, it opens my application correctly, but if I explore to that file path; where the file is located, and try to open it, my phone says no application can open this file-type.
在如何解决这个问题的任何想法?
Any ideas on how to solve this problem?
推荐答案
一些情况下有点棘手,我已经决定使用:
Some cases are kinda tricky, I've settled on using:
<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="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*.myFileExt" />
<data android:host="*" />
</intent-filter>
和这有时会失败,因为有时只是一个更加全球化的MIME类型(在我的情况下,XML)的使用:
and this sometimes fails because sometimes only a more global mime type (in my case XML) is used:
<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:mimeType="text/xml" />
</intent-filter>
相关推荐
最新文章