2016-09-14 27 views
9

我希望我的應用在http://www.example.comhttps://www.example.com上打開。Android深層鏈接架構:匹配http和https

這工作:

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

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

是否有可能與一個進入她倆?我試過了:

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

但這隻捕獲http鏈接,而不是https鏈接。

所以我知道我可以如何處理bot變種,但想用最簡潔的書寫方式。

+0

這是不可能的,我認爲 –

+0

我也認爲,這是不可能的。 –

+0

我不認爲這個字段支持正則表達式,但你可以嘗試'android:scheme =「https?」' –

回答

2

這似乎這樣的伎倆對我來說:

<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

您可以使用單獨的<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="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> 
+1

這就是我想要避免的,我想擁有最短的(就我的清單中的字符而言)可能性。 – FWeigl

+0

有時你無法避免,除非你要改變操作系統編碼:) –

+0

已經如此擔心;)無論如何。 – FWeigl