Question

Are there different steps to register an Android Activity as a BROWSABLE intent on Android 2.3 (API level 10) and earlier versions?

I've set up an Activity with an intent filter that uses a custom scheme:

<intent-filter>
    <action name="android.intent.action.VIEW"/>
    <category name="android.intent.category.DEFAULT"/>
    <category name="android.intent.category.BROWSABLE"/>
    <data scheme="@string/myCallbackProtocol"/>
</intent-filter>

On a physical device running 2.3, and with the SDK's simulator set to 2.3, the browser application directs links using my custom protocol to the app.

However, if I scale back the simulator to 2.2 or 2.1 then the browser does not redirect but instead indicates the server cannot be found. I don't have an actual device running these API levels.

I would like to release my app so it's compatible with devices running 2.1 and greater. Am I wrong to assume this should be possible? According to the Android docs Intent.CATEGORY_BROWSABLE has been available since 1.0.

Thanks!

Was it helpful?

Solution 2

Solved. BROWSABLE works back at least as far as Android 2.1. Before 2.3 it seems that loading the <data scheme=""> from a string resource leads to the Activity not being registered correctly.

Changing the @string/ reference to a hard-coded value yields the desired result.

<intent-filter>
    <action name="android.intent.action.VIEW"/>
    <category name="android.intent.category.DEFAULT"/>
    <category name="android.intent.category.BROWSABLE"/>
    <data scheme="my-custom-protocol"/>
</intent-filter>

OTHER TIPS

I have had no problems using BROWSABLE going back at least to 2.1 if not earlier. However, I have not implemented a custom scheme, let alone one defined in a string resource. Here is a sample project demonstrating the use of BROWSABLE.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top