我的 list :
<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>
结果:
- > http://authman.net/keepme.mht <--- 选择器不显示我的程序作为选项
- > http://authman.net/flipcode.mht <--- 选择器将我的程序显示为一个选项
很好奇,不是吗?我在这里做错了什么?同样奇怪——我的 list :
<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: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 intent filter: associate app with file extension
这是我的新 list ,对于那些可能从中受益的人:
<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>
关于安卓文件关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8903443/