Android deep linking schema: match both http and h

2019-04-19 18:10发布

I want my app to open on http://www.example.com and https://www.example.com.

This works:

            <data
                android:host="www.example.com"
                android:path="/"
                android:scheme="http"/>

            <data
                android:host="www.example.com"
                android:path="/"
                android:scheme="https"/>

Is it possible to catch both with one entry? I tried:

            <data
                android:host="www.example.com"
                android:path="/"
                android:scheme="http*"/>

but this catches only the http link, not the https one.

So I know how I can handle bot variants, but want to use the most concise writing possible.

2条回答
不美不萌又怎样
2楼-- · 2019-04-19 18:49

You can use seperate <intent-filter> for both

<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:host="www.example.com"
            android:path="/"
            android:scheme="http"/>     
</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:host="www.example.com"
            android:path="/"
            android:scheme="https"/>     
</intent-filter>
查看更多
唯我独甜
3楼-- · 2019-04-19 18:59

This seems to do the trick for me:

<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="http" />
    <data android:scheme="https" />
    <data android:host="www.mywebsite.com" />
    <data android:pathPrefix="/mypage.php" />
</intent-filter>
查看更多
登录 后发表回答