Dropbox Chooser中未显示Android App

时间:2013-04-28 15:55:29

标签: android intentfilter

我有我的应用程序的生产和测试版本。两者之间的唯一区别是包名称,因此两者可以同时安装在同一设备上。

这两个应用都有一个intent-filter,可以将它们与以下文件类型相关联     机器人:mime类型=“应用/八位字节流”     机器人:pathPattern = “* \ MYFILE”

步骤1.我安装了生产版本,并在dropBox中打开一个文件。结果确定:我的制作版本出现在“选配器”菜单中。

步骤2.我安装测试版,然后在dropBox中打开一个文件。结果失败:只有生产版本出现在选配器菜单中。

步骤3.我卸载生产版本,然后在dropBox中打开一个文件。结果确定:“选配器”菜单中仅显示测试版本。

在第2步之后,我还测试了其他一些应用,但比较结果可能不相关,因为内容方案和mimeTypes不同。

Gmail 确定(内容方案为“内容:”,mimeType为“application / octet-stream”

Google云端硬盘确定(内容方案为“文件:”,mimeType为“application / vnd.my.custom.type”

Evernote 失败(内容方案“内容:”,mimeType为“application / octet-stream”

Evernote失败,因为它创建的Intent既没有提供正确的mimeType,也没有提供正确的文件扩展名!

以下是我正在使用的所有意图过滤器

        </intent-filter>
        <!--
            Intent-filter for restoring via apps that use the file scheme, 
            and preserve the file-name, but not the MIME type, e.g. Dropbox.
        -->
        <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:host="*"
                android:mimeType="application/octet-stream"
                android:pathPattern=".*\\.wsctry"
                android:scheme="file" />
        </intent-filter>

        <!--
             Intent-filter for restoring via apps that use the content scheme, preserve
             the MIME type, but not the file name.
        -->
        <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:host="*"
                android:mimeType="application/vnd.winesecretary.com.backup"
                android:scheme="content" />
            <!-- Some apps (e.g. some versions of Gmail) use the file suffix as the mimeType! -->
            <data
                android:host="*"
                android:mimeType="application/wsctry"
                android:scheme="content" />
        </intent-filter>
        <!--
            Intent-filter for restoring via Google Drive and
            other apps that use the file scheme and preserve the 
            MIME type.
        -->
        <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:host="*"
                android:mimeType="application/vnd.winesecretary.com.backup"
                android:scheme="file" />
        </intent-filter>

        <!-- Special cases for some versions of Gmail -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

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

            <!--
            Gmail uses some strange mimeTypes when opening WS backup attachments,
            and none of them correspond to the original mimeType given by WS itself!
            -->
            <data
                android:host="gmail-ls"
                android:mimeType="application/octet-stream"
                android:scheme="content" />
        </intent-filter>

1 个答案:

答案 0 :(得分:1)

我简化了intent-filters后问题就消失了。

这就是我现在使用的

<!-- Intent-filter for Intents that contain the file suffix. -->
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <!--  For a path to be meaningful, both a scheme and an authority must be specified. -->
    <data
        android:mimeType="*/*"
        android:host="*"
        android:scheme="file"
        android:pathPattern=".*\\.wsctry" />
</intent-filter>

<!-- Intent-filter for Intents that contain a MIME type -->
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <!-- This is the original mimeType which was used when creating the file. -->
    <data android:mimeType="application/vnd.winesecretary.com.backup" />

    <!-- Some apps (e.g. some versions of Gmail) use the file suffix as the mimeType! -->
    <data android:mimeType="application/wsctry" />

    <!-- Gmail sometimes uses some strange mimeTypes when opening attachments -->
    <data
        android:host="gmail-ls"
        android:mimeType="application/octet-stream" />
</intent-filter>