Frank Harper
Frank Harper

Reputation: 3156

Android App not shown in Dropbox Chooser

I have production and test versions of my app. The only difference between the two is the package name, so that both can be installed at the same time on the same device.

Both apps have an intent-filter that associates them with the following file type android:mimeType="application/octet-stream" android:pathPattern=".*\.myfile"

Step 1. I install the production version, and open a file in dropBox. RESULT OK: my production version appears in the Chooser menu.

Step 2. I install the test version, and open a file in dropBox. RESULT FAIL: only the production version appears in the Chooser menu.

Step 3. I uninstall the production version, and open a file in dropBox. RESULT OK: only the test version appears in the Chooser menu.

After step 2, which I also tested with some other apps, but comparing results may not be relevant, because the content scheme and mimeTypes are different.

Gmail OK (content scheme is "content:", mimeType is "application/octet-stream")

Google Drive OK (content scheme is "file:", mimeType is "application/vnd.my.custom.type")

Evernote FAIL (content scheme is "content:", mimeType is "application/octet-stream")

Evernote fails because the Intent it creates gives neither the correct mimeType, nor the correct file extension!

Below are all the intent filters I'm using

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

Upvotes: 1

Views: 1131

Answers (1)

Frank Harper
Frank Harper

Reputation: 3156

The problem disappeared after I simplified the intent-filters.

This is what I am using now

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

Upvotes: 1

Related Questions