I am trying to create a file association for my application. I added the following intent filter to the activity in the manifest:
<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:mimeType="application/zip" />
<data android:mimeType="application/x-compressed" />
<data android:mimeType="application/x-zip-compressed" />
<data android:mimeType="application/x-zip" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\.zip" />
</intent-filter>
Now when I use the default android browser and I download a zip file, after it is finished I can tap on the downloaded file in the notification bar and it will list my application as on of 3 options to open it. Unfortunately after you click on the downloaded item in the notification bar it dissapears from there. So I open the "My Files" application and go to the download folder. However when selecting the zip file it says there are no applications associated with the type of file.
Is this a bug in the "My Files" application that comes with Android (or Samsung) or do I need to add alternative intent filters?
Try adding the following filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" android:host="*" android:pathPattern=".*\\.zip" android:mimeType="*/*" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.zip" android:mimeType="*/*" />
</intent-filter>
The scheme is likely a content or a file. You can find out by looking in the debugger for ActivityManager log lines.
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