Android deep linking schema: match both http and https

笑着哭i 提交于 2019-12-22 01:38:13

问题


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.


回答1:


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>



回答2:


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>


来源:https://stackoverflow.com/questions/39486852/android-deep-linking-schema-match-both-http-and-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!