This has been discussed in general previously, but I now have a specific case. My app opens a particular app-specific file type (.gedstar), which is actually a SQLite database and generally handled as application/octet-stream with a pathPattern qualifier. This is my Intent definition:
<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>
<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="*/*"
android:pathPattern=".*\\.gedstar"
android:host="*" />
</intent-filter>
(I've had it with and without the wildcarded mimeType, BTW). Up to now, I've been recommending the use of Dropbox to transfer the file from the user's PC to Android and launch my app, and this has been working well up until recently. Then, with the release of the Dropbox V2.0 app, it broke, resulting in the toast message about not having an app for this file type.
Trapping it with Logcat, this is the intent that does NOT work, which looks to me like it should:
I/ActivityManager( 97): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/Android/data/com.dropbox.android/files/scratch/GedStar%20Pro/Gordon.gedstar typ=application/octet-stream flg=0x10000003 (has extras) }
The strange thing is that I can download this same file using Dropbox's browser interface, then go to the browser's list of downloads and launch it successfully. Here is the SUCCESSFUL intent:
I/ActivityManager( 97): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/download/Gordon.gedstar typ=application/octet-stream flg=0x10000000 cmp=com.ghcssoftware.gedstar/.GedStar }
The only differences I see are the value of "flg" and the "cmp=" value which I assume is because the ActivityManager found a matching intent. Can anyone explain this more fully?
Thanks to Dropbox's tech support, it turns out that I was not the only one having this issue, and the reason is the "com.dropbox.android" in the Intent string, containing those extra dots. Turns out that the pathPattern matching is not "greedy" and thus is broken by the first dot in the spec. It would also break if the user has a dot in a directory or file name! The solution (do we still use the word "kludge"?) is to supply a bunch of intent filters with pathPatterns such as:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.ALTERNATIVE"/>
<data android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\\..*\\..*\\..*\\.gedstar"
android:host="*" />
</intent-filter>
This matches a path with three dots preceding the ".gedstar" string. The idea would be to include multiple intents to cover as many dots as could be expected. Ugly, but it DOES work now!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With