I am trying to make an android app to open files with extension .abc and this is my application section from android manifest xml
First of all, the first intent-filter
in your example uses MIME type image/jpeg
. Is jpeg
your .abc
extension?
I think there may be three reasons why this does not work:
You need to add more MIME types. Try adding the following:
<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/abc"/>
</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:mimeType="application/octet-stream"/>
</intent-filter>
And, if your .abc
format is a text format:
<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="text/plain"/>
</intent-filter>
You have registered the file
scheme. You might also need the content
scheme:
<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="content" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.abc" />
<data android:host="*" />
</intent-filter>
Rumor has it that pathPattern
with a dot only matches files containing a single dot. In your example, this would mean that your app would be associated with One.abc
but not with Two.Dots.abc
. Try adding more pathPatterns .*\\..*\\.abc
, .*\\..*\\..*\\.abc
etc.:
<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="*/*" />
<data android:pathPattern=".*\\..*\\.abc" />
<data android:host="*" />
</intent-filter>