Search code examples
androidrssandroid-intentintentfilter

How to open my Android app when rss link is opened in browser?


I'm creating an rss aggregator for my Android phone. I'd like to be able to subscribe to an rss feed from the browser since most websites have a subscribe via rss button.

How can I build an intent filter to receive those links?

This question was similar and showed how to create an intent filter to handle browser links: Make a link in the Android browser start up my app?

However, I don't know how to make it specific to rss feeds. As an attempt I tried this filter:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="application/rss+xml" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" /> 
        </intent-filter>

Am I on the right track? What should I be filtering on?


Solution

  • Turns out there's a lot of different ways podcasts can be set up so each intent filter will only work for some of them. A lot of different filters need to be used to get the desired effect over most subscribe links.

    Here's some of the filters I found that worked:

    <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <data android:scheme="itpc" />
                    <data android:scheme="pcast" />
                    <data android:scheme="feed" />
                    <data android:scheme="rss" />
                </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" android:host="*"
                        android:pathPattern=".*xml" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*rss" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*feed.*" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*podcast.*" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*Podcast.*" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*rss.*" />
                    <data android:scheme="http" android:host="*"
                        android:pathPattern=".*RSS.*" />
                </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:mimeType="text/xml" android:scheme="http" />
                    <data android:mimeType="application/rss+xml" android:scheme="http" />
                    <data android:mimeType="application/atom+xml" android:scheme="http" />
                </intent-filter>