三星文件浏览器的意图过滤器异常行为 [英] Intent-filter abnormal behavior with samsung file browser

查看:144
本文介绍了三星文件浏览器的意图过滤器异常行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用程序的特定扩展名(.infi)创建一个意图过滤器.它可以与ES文件浏览器&一起正常使用.坚实的资源管理器.但是,当我使用Samsung默认文件浏览器(Device Galaxy Tab S2)打开文件时,它显示一条奇怪的消息没有应用程序可以执行此操作",在其他设备上(注4),它尝试使用Adobe Reader打开文件并出现错误信息.这是清单文件中的代码:

I'm creating an intent filter for a specific extension (.infi) for my app. It works correctly with ES file explorer & Solid explorer. However when I open the file with Samsung default file explorer (Device Galaxy Tab S2) it shows a strange message "No application to perform this action", on other device (Note 4) it tries to open the file with Adobe Reader with an error message. Here is my code from manifests file :

<activity android:name=".ImportCollections">
        <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:mimeType="*/*" />
            <data android:pathPattern=".*\\.infi" />
        </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="http" />
            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.infi" />
        </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="content" />
            <data android:mimeType="application/octet-stream" />
            <data android:pathPattern=".*\\.infi" />
            <data android:host="gmail-ls" />
        </intent-filter>


    </activity>

推荐答案

为以后的参考,我寻找了另一个正确实现此功能的开源应用程序.这些家伙做得很好:

For future references, I looked for another open source app implementing this feature correctly. These guys are doing a great job:

https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml

这是我的代码正常工作(只需将"infi"替换为您的自定义扩展名即可)

Here is my code that worked (just replace "infi" with your custom extention)

<activity
        android:name=".ImportCollections"
        android:launchMode="singleTask"
        android:parentActivityName=".ManageCollections">
        <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:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="http" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="https" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="content" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="file" />
        </intent-filter>
        <!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/infi" />
            <data android:mimeType="application/x-infi" />
            <data
                android:mimeType="application/octet-stream"
                android:scheme="content" />
            <data
                android:mimeType="application/zip"
                android:scheme="content" />
        </intent-filter>
    </activity>

这篇关于三星文件浏览器的意图过滤器异常行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆