This question has been asked [numerous times] before, but I have not seen any definitive answers, or examples of code that actually works.
I would like to associate an Activity with a particular file type.
For discussion, assume that I want my Activity to be associated with PDFs.
Here is what I currently have. I have experimented with many different values and combinations of values in the intent-filter, but I have yet to get my Activity to start when a PDF is selected.
<activity name="com.mycompany.MyActivity"> <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" /> <data android:mimeType="application/pdf" /> <data android:pathPattern="\\*\\.pdf" /> <data android:host="*" /> </intent-filter> </activity>
Does anyone know how to actually make this work?
Have you tried with that simple version :
Your pathPattern is definitively wrong and you are restricting it too much with the mimetype.
Try the following:
To open both local and remote pdf files I'd do: