我需要使用我的应用程序打开具有自定义扩展名的文件。当文件位于我的 SD 卡中时,我可以使用 Intent 过滤器来执行此操作。如果文件作为 Gmail 附件发送,我还可以查看“下载”和“预览”按钮。但是,当我单击下载/预览按钮时,我收到消息 -“抱歉,附件无法下载”.
我认为这是我的应用程序的问题。但我突发奇想,在手机上安装了“下载所有文件”应用程序。然后,当我单击 Gmail 中的下载按钮时,建议同时下载所有文件和我的应用程序来下载文件。我选择了我的应用程序,一切正常!
这是一些安全问题吗?
这些是我的意图过滤器:
<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="*/*" />
<data android:scheme="content" android:host="*"
android:pathPattern=".*\\.ate" />
<data android:scheme="file" android:host="*"
android:pathPattern=".*\\.ate" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/*" host="*" android:pathPattern=".*.ate" android:scheme="content" />
</intent-filter>
编辑:这是完整的活动标签。
<activity android:name=".TestApp"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.TestApp.TestApp.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- Opening .ate file start -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.ate" />
</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="*/*" />
<data android:scheme="content" android:host="*"
android:pathPattern=".*\\.ate" />
<data android:scheme="file" android:host="*"
android:pathPattern=".*\\.ate" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="file" android:pathPattern=".*\\.ate" android:mimeType="application/octet-stream"/>
<data android:scheme="content" android:pathPattern=".*\\.ate" android:mimeType="application/octet-stream"/>
</intent-filter>
<!-- Opening .ate file end -->
</activity>
我自己解决了这个问题,所以我发布解决方案,以防其他人遇到这个奇怪的问题。
意图过滤器需要内容和文件方案类型,其中 mimetype application/octetstream
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="file" android:pathPattern=".*\\.inform" android:mimeType="application/octet-stream"/>
<data android:scheme="content" android:pathPattern=".*\\.inform" android:mimeType="application/octet-stream"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)