Android文件关联

Android文件关联,android,android-manifest,mime-types,file-association,Android,Android Manifest,Mime Types,File Association,我的舱单: <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data andr

我的舱单:

<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=".*mht" />
    <data android:scheme="https" android:host="*" android:pathPattern=".*mht" />
</intent-filter>
<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="message/rfc822" android:scheme="http" />
    <data android:mimeType="multipart/related" android:scheme="http" />
    <data android:mimeType="message/rfc822" android:scheme="https" />
    <data android:mimeType="multipart/related" android:scheme="https" />
</intent-filter>
结果:


从网站检索文件时,能否验证这两个文件中的内容类型?如果他们显示不同的类型,我会期望不同的行为,可能web服务器正在解释数据,并在每个文件中看到不同的触发器

我在检查了标题,第二个文件已经不存在了,所以我无法比较

另一个可能会影响事情的问题——除非您将用户代理设置为与您的Android设备将要使用的内容相匹配,否则您可能会在桌面浏览器或web嗅探器上得到不同的结果


不确定这是否是导致问题的原因,但值得验证。

从网站检索文件时,能否验证两个文件中的内容类型?如果他们显示不同的类型,我会期望不同的行为,可能web服务器正在解释数据,并在每个文件中看到不同的触发器

我在检查了标题,第二个文件已经不存在了,所以我无法比较

另一个可能会影响事情的问题——除非您将用户代理设置为与您的Android设备将要使用的内容相匹配,否则您可能会在桌面浏览器或web嗅探器上得到不同的结果


不确定这是否是导致您出现问题的原因,但值得验证。

这里第一个答案中的建议帮助了我:

这是我的新清单,给那些可能从中受益的人:

<intent-filter
    android:icon='@drawable/ic_launcher'
        android:label='AndroidMHT File'
    android:priority='1'>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" /> 
    <action android:name="android.intent.action.PICK" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:mimeType="*/*" />
    <data android:pathPattern="*.mht" />
</intent-filter>
<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=".*\\.mht" />
    <data android:scheme="https" android:host="*" android:pathPattern=".*\\.mht" />
</intent-filter>
<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="message/rfc822" android:scheme="http" />
    <data android:mimeType="multipart/related" android:scheme="http" />
    <data android:mimeType="message/rfc822" android:scheme="https" />
    <data android:mimeType="multipart/related" android:scheme="https" />
</intent-filter>

第一个答案中的建议帮助了我:

这是我的新清单,给那些可能从中受益的人:

<intent-filter
    android:icon='@drawable/ic_launcher'
        android:label='AndroidMHT File'
    android:priority='1'>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" /> 
    <action android:name="android.intent.action.PICK" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:mimeType="*/*" />
    <data android:pathPattern="*.mht" />
</intent-filter>
<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=".*\\.mht" />
    <data android:scheme="https" android:host="*" android:pathPattern=".*\\.mht" />
</intent-filter>
<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="message/rfc822" android:scheme="http" />
    <data android:mimeType="multipart/related" android:scheme="http" />
    <data android:mimeType="message/rfc822" android:scheme="https" />
    <data android:mimeType="multipart/related" android:scheme="https" />
</intent-filter>

您可以尝试更改以下属性

android:mimeType="text/*"
android:pathPattern="*.mht"

您可以尝试更改以下属性,以查看您的意图过滤器

android:mimeType="text/*"
android:pathPattern="*.mht"

到您的意图过滤器

好的,使用这里的响应,我能够使第二部分SD卡文件系统部分正常工作。但是第一部分,HTTP部分不工作。好的,使用这里的响应,我能够使第二部分SD卡文件系统部分工作。但是第一部分,HTTP部分不起作用。很抱歉。我刚把第二个文件放回去。我正在点击GMail安卓客户端的链接,所以我不确定它是否会在启动意图之前检查标题。但例如,如果我将keepme.mht复制到我的SD卡上并双击它,它会给我上下文菜单。但是web链接上的同一个keepme.mht不是我比较了dl'd文件和原始文件的内容,它们是相同的。浏览器可能会进行一些检查,并根据数据确定内容类型。我看到这两个文件使用不同的字符集,这可能是相关的。第二个文件的顶部还有一些额外的行。也许你需要做一些调查,看看它处理第二个文件是什么类型的,并添加一个过滤器来捕获它。很抱歉。我刚把第二个文件放回去。我正在点击GMail安卓客户端的链接,所以我不确定它是否会在启动意图之前检查标题。但例如,如果我将keepme.mht复制到我的SD卡上并双击它,它会给我上下文菜单。但是web链接上的同一个keepme.mht不是我比较了dl'd文件和原始文件的内容,它们是相同的。浏览器可能会进行一些检查,并根据数据确定内容类型。我看到这两个文件使用不同的字符集,这可能是相关的。第二个文件的顶部还有一些额外的行。也许你需要做一些调查,看看它处理第二个文件是什么类型的,并添加一个过滤器来捕获它。。我正在尝试做同样的事情,研究了很多,尝试了数百个意图过滤器,但最终你的代码工作了..非常感谢!!非常感谢@Authman。。我正在尝试做同样的事情,研究了很多,尝试了数百个意图过滤器,但最终你的代码工作了..非常感谢!!