5

I have an activity that I want to run every time the user goes to an xml (specifically rss) page in the browser (at least assuming the user get's it from the list of apps that can support it).

I currently already have the current intent filter:

    <activity android:name=".activities.EpisodesListActivity"
        android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <category android:name="android.intent.category.DEFAULT"></category>
            <action android:name="android.intent.action.VIEW"></action>
            <data android:scheme="http"></data>
        </intent-filter>
    </activity>

Now as you can guess, this is an evil intent, as it wants to open whenever a page is requested via http. However, when I ad the line:

<data android:mimeType="application/rss+xml"></data>

to make it:

    <activity android:name=".activities.EpisodesListActivity"
        android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <category android:name="android.intent.category.DEFAULT"></category>
            <action android:name="android.intent.action.VIEW"></action>
            <data android:scheme="http"></data>
            <data android:mimeType="application/rss+xml"></data>
        </intent-filter>
    </activity>

The application no longer claims to be able to run rss files.

Also, if I change the line to:

<data android:mimeType="application/xml"></data>

It also won't work (for generic xml file even).

So what intent filter do I need to make in order to claim that the activity supports rss.

(Also, bonus points if you can tell me how I know what URL it was the user opened. So far, I've always sent that information from one activity to the other using extras).

Thank you for your help

Leif Andersen
  • 21,580
  • 20
  • 67
  • 100

1 Answers1

1

try this as your intent-filter

        <intent-filter android:label="@string/app_name">
            <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/rss+xml" />
            <data android:mimeType="application/atom+xml" />
            <data android:mimeType="application/xml" />
            <data android:mimeType="text/xml" />
        </intent-filter>
Nathan Schwermann
  • 31,285
  • 16
  • 80
  • 91
  • Nope, it didn't work. :( Is there any more information I can give to shed some light on the situation? – Leif Andersen Jan 04 '11 at 01:20
  • Hmm...here's the line from logcat which I believe is starting the intent: 01-03 18:21:29.651: INFO/ActivityManager(1259): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://leoville.tv/podcasts/tnt.xml cmp=android/com.android.internal.app.ResolverActivity }, but when the activity chooser pops up, my app isn't in the list (only the browser and google voice is). – Leif Andersen Jan 04 '11 at 01:23
  • hmm not sure, I just used apktool to look at the intent filter the google reader app uses because I knew it could do this. I haven't seen any good blogs or documentation on this type of thing. – Nathan Schwermann Jan 04 '11 at 01:40
  • Mmmm...also I've looked at the AndroidManifest.xml file for google listen (from aapt), and it seems to do something similar to this, registering the mimeType and data types, the only difference is that it has an additional intent-filter for feedburner...go figure. Oh well, thanks anyway, I'll keep looking to see if I can find another solution. – Leif Andersen Jan 04 '11 at 15:09