Search code examples
javaandroidandroid-intentintentfilter

Android intent filter for a non-launcher activity


I am trying to add an intent filter for a special extension to my activity (non-launcher). But in file-managers, such as TotalCommander and others - the files are still not associated with my app, and Android doesn't suggest my app to open these file when i am trying to open them from file-manager. But when i moved my intent-filter - to the launcher activity - everything start working fine. So i am wondering - the intent filter for extensions should be added only to the activity that is declared as a launcher in Manifest? Thanks

This is my 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=".*\\.myext"/>
 </intent-filter>

Solution

  • Just add the host

    <data android:host="*" />
    

    If a host is not specified for the filter, the port attribute and all the path attributes are ignored.

    Learn more here.