7

I'm trying to register my Android app as a handler for iCal URLs. To do this I set intent filters in my Manifest for the webcal:// pseudo protocol and for HTTP URLs using the text/calendar MIME type (see below).

This works perfectly fine in the emulator, but on a real device I'm having problems. The webcal:// filter works, but the text/calendar one doesn't. Instead the Browser displays the ical file as plain text instead of passing the URL to my app.

I checked that the browser isn't configured as a default handler for ical (in Settings->Applications->Browser) and I asked a few other people if they could reproduce the problem on their mobiles. All with the same result.

What's the correct way to register for text/calendar URLs?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.splitbrain.giraffe"
  android:versionName="0.31" android:versionCode="4">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar">
    <activity android:label="@string/app_name" android:name="MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <action android:name="android.intent.action.VIEW"></action>
            <data android:mimeType="text/calendar" android:scheme="http"></data>
            <category android:name="android.intent.category.DEFAULT"></category>
        </intent-filter>
        <intent-filter>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <action android:name="android.intent.action.VIEW"></action>
            <data android:scheme="webcal"></data>
            <category android:name="android.intent.category.DEFAULT"></category>
        </intent-filter>
    </activity>
    <activity android:name="OptionsActivity"></activity>
    <activity android:name="DetailActivity"></activity>
    <activity android:name="AboutActivity"></activity>

</application>
</manifest>

Update: Turns out the above works fine in the Android 1.6 emulator, but not on a 2.3.3 emulator where it shows the same behavior as on my phone. Is this a bug in Android maybe?

3
  • Is it possible the server is not accurately sending down the correct Content-Type? If it isn't, the browser might just interpret it as plain text. You might have better luck with a path intent filter too that regexes *.ical Jul 21, 2011 at 5:10
  • Yes, the server sends the correct mime-type. Here's the URL I use for testing: re-publica.de/11/rp2011.ics Jul 21, 2011 at 9:41
  • Have you tried another filter with the path parameter approach for *.ics? If that doesn't work is it possible you have the default app set to be the browser so that it doesn't prompt anymore? Jul 22, 2011 at 5:43

2 Answers 2

0

I opened a bug report at https://code.google.com/p/android/issues/detail?id=18796

0

Just use the DEFAULT category, the BROWSABLE category is might be causing the problem.

Add a .*.ics path pattern to capture any files that have been given the wrong mime type by the server

Put all the data matching into the same filter

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.splitbrain.giraffe"
  android:versionName="0.31" android:versionCode="4">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar">
    <activity android:label="@string/app_name" android:name="MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/calendar" />
            <data android:scheme="webcal" />
            <data android:pathPattern=".*.ics" />
        </intent-filter>
    </activity>
    <activity android:name="OptionsActivity"></activity>
    <activity android:name="DetailActivity"></activity>
    <activity android:name="AboutActivity"></activity>

</application>
</manifest>
3
  • Nope. No difference. Even with the *.ics pathPattern and the rules exactly as you gave them, the browser continues to display the data instead handing the URL over to my application. Jul 25, 2011 at 18:39
  • 1
    I believe that the expression you are looking for is: ".*.ics" see the docs for more info: developer.android.com/guide/topics/manifest/data-element.html
    – TheIT
    Mar 27, 2014 at 3:46
  • @TheIT well spotted! This is an ancient post, but I hope somebody finds it useful. I'll update the answer. Should it not be .*\.ics to escape he second period?
    – Moog
    Mar 27, 2014 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.