Psest328
Psest328

Reputation: 6675

Deep linking using end of URL

I've got deep linking working, but the issue I'm running into is that depending on the final element in the URL, I have to redirect the user to different parts of the app.

So right now I'm working with "http://www.mypage.com/us/en/order.html", but we're in multiple countries so it could also be "http://www.mypage.co.uk/uk/en/order.html".

What I'm looking to do is catch the last element (order.html) and deep link using that.

Below is what I currently have, but it catches all browser activity

<activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:taskAffinity="com.mypage.app"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan">
            <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="mypagemobileapp"/>
                <data android:scheme = "http"
                    android:host="www.mypage.com"/>
            </intent-filter>
        </activity>

Upvotes: 2

Views: 430

Answers (1)

dthulke
dthulke

Reputation: 949

Have a look at the documentation of the data element: http://developer.android.com/guide/topics/manifest/data-element.html

You can specify a pattern for the path of your url. In your case you should use something like the following

<data android:scheme="http"/>
<data android:host="www.mypage.com"/>
<data android:host="www.mypage.co.uk"/>
<data android:pathPattern=".*/.*/order\\.html"/>

to match all country / language combinations for the page. If you have to match other pages you can adapt the pattern accordingly.

Upvotes: 2

Related Questions