Search code examples
androidandroid-intentgoogle-drive-android-api

Intent from Google Drive when file is selected


Since first developed for Android 2.3, my app, which uses SQLite files that are generated on a user's PC, has used the following intent in order to be informed that the user has selected one of its files in either Dropbox or Drive. (I actually have several similar intents in the manifest to support various levels of directory hierarchy.):

    <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:scheme="file"
                android:mimeType="application/octet-stream"
                android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.gedstar"
                android:host="*" />
    </intent-filter>

When the app receives this intent, it uses it to open and copy the file to its own specific directory in the main file storage. It's been so long ago that I don't recall where I got this structure from, but up to now it has continued to work. However, starting with Android 6.0, it no longer works for Google Drive, and I get an "Unsupported file type" message. Dropbox is still OK.

I assume that the Intent issued by Drive has recently changed. Does anyone know how it is now implemented so I can provide the correct intent-filter?


Solution

  • I discovered an app called Intent Intercept that let me do exactly what the name implies: intercept the Intent that Drive issues when selecting my file in the Drive app. It's not at all what I was expecting according to other Drive documentation, but at least I now have that part figured out and can get a content URI to work with.