1

I have an application that wants to handle SGF files. It has these filters in the manifest:

        <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="http"/>
            <data android:host="*"/>
            <data android:pathPattern=".*\\.sgf"/>
        </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="http"/>
            <data android:mimeType="application/x-go-sgf"/>
        </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:host="*" />
            <data android:pathPattern=".*\\.sgf"/>
        </intent-filter>

The idea is to handle SGF files opened in the browser or from a file. This was working until recently. I'm not sure exactly when it stopped working, but it wasn't because of a code change. I have another application that is trying to start the activity and it's getting an exception:

No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/gogrinder/Mastering%20the%20Basics/Vol.%202%20-%20One%20Thousand%20and%20One%20Life-and-Death%20Problems/6%20-%20Five-move%20problems%20-%20Black%20to%20kill/prob144.sgf }

Shouldn't this intent match one of the filters above? Opening an SGF file from the browser or file explorer does cause my activity to start, but doing it programmatically as above doesn't work anymore.

TimK
  • 6,940
  • 9
  • 39
  • 46

1 Answers1

0

I also have an app which opens SGF files, and it works fine. Compared to your code, I added additional mimeType and host attributes :

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:host="*" />
            <data android:scheme="file" />
            <data android:pathPattern=".*\\.sgf" />
            <data android:mimeType="*/*" />
        </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:host="*" />
            <data android:scheme="http" />
            <data android:pathPattern=".*\\.sgf" />
            <data android:mimeType="*/*" />
        </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:host="*" />
            <data android:scheme="http" />
            <data android:mimeType="application/x-go-sgf" />
        </intent-filter>

If it still doesn't work, it may be a problem with the file path. The pathPattern doesn't work very well when the path includes several dots. Check this question :

pathPattern to match file extension does not work if a period exists elsewhere in the file name?

Community
  • 1
  • 1
Dalmas
  • 25,439
  • 9
  • 62
  • 75
  • There is an extra dot in the path, but that doesn't seem to be the problem. I tried a file without an extra dot, and it still doesn't work. – TimK Sep 05 '12 at 13:22