I am trying to make an android app to open files with extension .abc and this is my application section from android manifest xml
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="com.example.app.ActName" android:label="AppName">
<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="image/jpeg"/>
</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" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.abc" />
<data android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
I used all the experience from the most popular and related questions
Android intent filter for a particular file extension?
Android intent filter: associate app with file extension
And in the end this does not work - when I click on a file named "name.abc" in ES file browser it asks me if i want to open the file as text or image etc. when it actually supposed to just open the file in my app instead
What am i doing wrong? What is the proper intent filter to launch the app by just clicking a file with the corresponding extension in any file manager?
upd.
it looks like different android systems and different file browsers act in different way - one intent filter works just fine on 4.2 in "ES File Explorer" and on 4.0.4 in default file manager, but does not work at all on 4.2 and 4.0.4 in "Total Commander" and on 4.0.4 in "ES File Explorer"
First of all, the first
intent-filter
in your example uses MIME typeimage/jpeg
. Isjpeg
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:
And, if your
.abc
format is a text format:You have registered the
file
scheme. You might also need thecontent
scheme: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 withOne.abc
but not withTwo.Dots.abc
. Try adding more pathPatterns.*\\..*\\.abc
,.*\\..*\\..*\\.abc
etc.: