【问题标题】:Android App not shown in Dropbox ChooserDropbox 选择器中未显示 Android 应用
【发布时间】:2013-04-22 07:05:52
【问题描述】:

我有我的应用的生产和测试版本。两者的唯一区别是包名,所以可以同时安装在同一台设备上。

这两个应用程序都有一个意图过滤器,将它们与以下文件类型相关联 android:mimeType="应用程序/八位字节流" android:pathPattern=".*\.myfile"

步骤 1. 我安装生产版本,并在 dropBox 中打开一个文件。结果正常:我的生产版本出现在选择器菜单中。

第 2 步。我安装了测试版,并在 dropBox 中打开了一个文件。结果失败:只有生产版本出现在选择器菜单中。

第 3 步。我卸载了生产版本,并在 dropBox 中打开了一个文件。结果正常:只有 test 版本出现在选择器菜单中。

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

Gmail OK(内容方案是"content:",mimeType 是"application/octet-stream"

Google DriveOK(内容方案是"file:",mimeType 是"application/vnd.my.custom.type"

Evernote FAIL(内容方案是"content:",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>

【问题讨论】:

  • 除了DropBox,你有没有尝试过?例如,您是否创建了自己的startActivity() 呼叫并尝试过?这将有助于区分 Android 问题和 DropBox 特定问题。
  • 感谢 CommonsWare 的建议,我创建了一个简单的 StartActivity() 调用。症状与 Dropbox 不同,但也无法正常工作。所以我简化了意图过滤器,现在 Dropbox 和简单的 StartActivity() 调用都可以工作了!

标签: android intentfilter


【解决方案1】:

在我简化了意图过滤器后问题就消失了。

这是我现在用的

<!-- 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 2020-06-12
    • 2014-05-11
    相关资源
    最近更新 更多