Search code examples
androidintentfilter

android:pathPattern has no effect on intent-filter behavior


I'd like to make my filter to pass only *.pls files. According the developer docs: http://developer.android.com/guide/topics/manifest/data-element.html it should be working (I think) but it's not. Instead of the expected behavior (passing .pls files only) all file types are being passed.

<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=".*\\.pls" />

</intent-filter>

Solution

  • If you re-read the docs you'll notice this line relating to the android:path, android:pathPrefix, and android:pathPattern

    These attributes are meaningful only if the scheme and host attributes are also specified for the filter.

    You are missing the android:host atttribute. Add

    <data android:host="*" />
    

    to your intent-filter as the docs specify