1

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!

sho
  • 759
  • 5
  • 16

2 Answers2

1

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • hello mark, i want my webview to load the url after it gets pasted in the url field , i tried this uri.setText(intentUri); webView.loadUrl(intentUri); but my app force closes. any clue? – JRE.exe Feb 11 '15 at 10:02
  • @JRE.exe: I would recommend that you ask a separate Stack Overflow question, where you provide your source code and stack trace. – CommonsWare Feb 11 '15 at 11:21
  • here sir http://stackoverflow.com/questions/28452610/load-url-from-browsable-intent-android/28453304?noredirect=1#comment45237116_28453304 – JRE.exe Feb 11 '15 at 13:16
  • i'm stuck on the same thing since the whole day, were you able to find a workaround? Thanks – JRE.exe Feb 11 '15 at 14:52
1

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>
sho
  • 759
  • 5
  • 16