安卓文件关联

标签 android android-manifest mime-types file-association

我的 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>

结果:

很好奇,不是吗?我在这里做错了什么?同样奇怪——我的 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/

相关文章:

安卓工作室 2.2.3 : Error Running App: Default Activity not found

android - 应用程序未显示在最近的应用程序列表中

ruby - 如何通过文件扩展名确定 mime 类型? ( ruby )

javascript - 文本/javascript 与应用程序/javascript

iis - 使用IIS以纯文本形式提供不带扩展名的文件

Android GCM 服务器错误 : Device Subscription Expired

android - Eclipse中的android布局文件问题

android - M 新保护级别列表?

android - 如何增加 Android PJSIP 中的麦克风音量?

android - 使用 Fragment 时相机预览不会填满整个屏幕