Why isn’t my app on the list of apps to open txt file?

You need to associate your app with file extension. To do so, add these two line within intent filter and u’r good to go

<data android:scheme="file" />
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.pdf" />

And your manifest would be look like this

<activity name="com.your.activity">
    <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=".*\\.txt" />
    </intent-filter>
</activity>

<data android:scheme="file" /> => this define that the file must be local, not from http or else

<data android:mimeType="*/*" /> => match any mime type

<data android:pathPattern=".*\\.txt" /> => this is where you specify what extension you want to match

Hope this help

Leave a Comment