无法获取的Andr​​oid火狐与指定的MIME类型打开的文件 [英] Can't get Android Firefox to open files with a mime-type specified

查看:210
本文介绍了无法获取的Andr​​oid火狐与指定的MIME类型打开的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序来处理文件名为*从浏览器,电子邮件或存储.mcmidi。

I want my app to handle files called *.mcmidi from browser, email or storage.

我发现下面的意图过滤器的数据元素适用于Android原生浏览器和Android的浏览器:

I have found that the following intent-filter data element works for android native browser and for android chrome:

<data android:scheme="content" android:mimeType="*/*" android:pathPattern=".*\\.mcmidi" />

和这部作品为Android火狐:

and this works for android firefox:

<data android:scheme="file" android:pathPattern=".*\\.mcmidi" />

但如果我尝试同时使用火狐然后停止能够打开下载的文件。它似乎像火狐如有意向过滤器指定一个mimeType没有工作。

but if I try to use both then firefox stops being able to open the downloaded files. It seems like firefox doesn't work if any intent-filter specifies a mimeType.

(我一直在测试这些意图过滤器试图找到一个作品无处不在这么多的组合)

(I've been testing so many combinations of these intent-filters trying to find one that works everywhere)

有谁知道为什么Firefox是这样,还是没有办法解决呢?

Does anyone know why firefox is doing this, or any way to work around it?

推荐答案

好吧,我的工作了。 Chrome和Android浏览器使用的方案=内容条目。 Firefox使用计划=文件条目。如果使用将mimeType =* / *条目,然后所有新的电子邮件警报将打开的应用程序选择器与我的应用程序,这也是白搭。从Gmail使用计划=内容,但不同的mime类型打开文件附件。文件浏览器的应用程序一般使用计划=文件的路径扩展。

Ok I worked it out. Chrome and Android browsers use the scheme="content" entry. Firefox uses the scheme="file" entry. If you use the mimeType="*/*" entry then all new email alerts will open the app chooser with my app, which is also no good. Opening file attachments from gmail use scheme="content" but with a different mimeType. File explorer apps generally use scheme="file" with the path extension.

由于它们都需要不同的意图过滤器,我使用活动的别名别名我的活动为不同的应用程序三种不同的方法,让他们全部通过文件内容我的应用程序并不会相互干扰或他们自己添加为通用文件处理程序(它总是很让人讨厌)。所以我有这样的:

Because they all need different intent-filters, I have used activity-alias to alias my activity three different ways for the different apps, so that they all pass the file content to my app and don't interfere with each other or add themselves as generic file handlers (which is always very irritating). So I have this:

<activity
    android:name="my.Activity"
    android:label="@string/label1"
    android:exported="true" >
    <!-- the main intent filter allows chrome and native browsers to open .mcmidi files with my app -->     
    <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="content" android:mimeType="application/x-mcmidi"  android:pathPattern=".*\\.mcmidi" />
    </intent-filter>
</activity>

<!-- This alias will cause file explorer apps to open *.mcmidi files with my app -->
<activity-alias
    android:name="my.ActivityFileAlias"
    android:targetActivity="my.Activity"
    android:label="@string/label1"
    android:exported="true" >

    <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" android:pathPattern=".*\\.mcmidi" />
    </intent-filter>
</activity-alias>

<!-- This alias will cause gmail and the native mail apps to open *.mcmidi files with my app -->
<activity-alias
    android:name="my.ActivityEmailAlias"
    android:targetActivity="my.Activity"
    android:label="@string/label1"
    android:exported="true" >

    <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="content" android:mimeType="application/octet-stream" android:pathPattern=".*\\.mcmidi" />
    </intent-filter>
</activity-alias>

这点我摸索出与试错的一些线索和载荷。希望它可以帮助别人。

Which I worked out with a few clues and loads of trial and error. Hope it helps someone.

这篇关于无法获取的Andr​​oid火狐与指定的MIME类型打开的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆