5

I need the browser to start my app whenever I enter the "myapp://blah.com/a?b=1&c=2" in the browser. I have searched a lot on this topic, but non of the answers really helped me. Could you please help to understand what I'm missing?

<activity android:name=".MyAppMain"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation" 
              android:screenOrientation="portrait">
        <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" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="myapp" /> 
        </intent-filter>
    </activity>

After installation from Eclipse (Run As Android application) my app can work ok on its own, but when I type in "myapp://blah.com/a?b=1&c=2", the browser is simply googling for this string. Could you point out what else I'm missing? Do I need after installation to somehow register in the system that I want to handle "myapp://" urls?

Programmer Bruce
  • 58,151
  • 6
  • 96
  • 93
user789175
  • 51
  • 1
  • 2
  • Does it work if you only use that one `` in your manifest? – Daniel DiPaolo Jan 19 '11 at 15:17
  • No, Daniel, it's still googling :-) – user789175 Jan 19 '11 at 15:41
  • @user789175 did you figure this out? – Phil Aug 16 '11 at 18:02
  • possible duplicate of [Launch custom android application from android browser](http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser) – Brad Larson Aug 23 '11 at 19:10
  • Launching apps via custom URL in Android browser has already been covered here: http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser – Jacob Robinson Aug 22 '11 at 20:45
  • Check out this answer for why it isn't working http://stackoverflow.com/questions/8463794/android-custom-uri-scheme-incorrectly-encoded-when-type-in-browser Basically, – Matthew Jan 23 '12 at 04:35

2 Answers2

0

I have done this using the

  <activity android:name=".ReceiveInviteActivity">

            <intent-filter >
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                 <data
                 android:scheme="appname" 
                 android:host="project.example.com"

                />
            </intent-filter>

        </activity>

And activity

 if (Intent.ACTION_VIEW.equals(action)) {
            final List<String> segments = intent.getData().getPathSegments();
            Log.d("LISTARRAY",segments.toString());
            String idString = segments.get(0);
            Log.d("LISTITEM",segments.get(0).getClass().toString());
            String friendId = idString.substring((idString.indexOf("="))+1);
            Log.d("friendId!",friendId);

I hope this will help you.

Sameer Z.
  • 3,237
  • 8
  • 45
  • 72
0

Check out this answer for why it isn't working: Android custom URI scheme incorrectly encoded when type in browser

Basically, the default Android browser only accepts certain URI schemes, so your custom one won't work when typed directly into the URL bar.

Community
  • 1
  • 1
Matthew
  • 5,961
  • 7
  • 42
  • 58