Android File Associations
我的清单:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <intent-filter> <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> <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> |
结果:
- http://authman.net/keepme.mht <---选择器未将我的程序显示为选项
- http://authman.net/flipcode.mht <---选择器将我的程序显示为一个选项
很好奇,不是吗? 我在这里做错了什么? 同样奇怪-我的清单:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <intent-filter android:icon='@drawable/ic_launcher' android:label='AndroidMHT File' android:priority='1'> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="file" /> <data android:scheme="content" /> <data android:mimeType="*/*" /> <data android:pathPattern=".*\\\\.mht" /> <data android:host="*" /> </intent-filter> |
结果:
- /mnt/SDCARD/Android/data/com.mht/files/flipie.mht <---选择器不会将我的程序显示为选项
- /mnt/SDCARD/Android/data/com.mht/files/keepme.mht <---选择器将我的程序显示为选项
我到头了。 任何帮助,不胜感激。
此处第一个答案中的建议对我有所帮助:Android意向过滤器:将应用程序与文件扩展名关联
这是我的新清单,对于那些可能会从中受益的人:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <intent-filter android:icon='@drawable/ic_launcher' android:label='AndroidMHT File' android:priority='1'> <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> <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> <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> |
您可以尝试更改以下属性
1 2 | android:mimeType="text/*" android:pathPattern="*.mht" |
到您的意图过滤器
从网站上检索文件时,可以验证两个文件中的内容类型吗?如果它们显示不同的类型,我会期望它们具有不同的行为(也许Web服务器正在解释数据并在每个文件中看到不同的触发器)。
我在http://web-sniffer.net/上检查了标头,并且第二个文件不再存在,因此无法进行比较。
可能会影响事情的另一个问题-除非您将用户代理设置为与您的Android设备将使用的匹配,否则您在台式机浏览器或网络嗅探器上可能会得到不同的结果。
不确定是不是引起您问题的原因,但值得验证。