2016-10-11 51 views
1

我有申請意向過濾器活動打開深層鏈接,這是我的意圖過濾器:Android的深層鏈接沒有Android:方案

<intent-filter android:autoVerify="true"> 
       <category android:name="android.intent.category.DEFAULT" /> 

       <action android:name="android.intent.action.VIEW" /> 

       <category android:name="android.intent.category.BROWSABLE" /> 

       <data 
        android:host="www.example.com" 
        android:pathPattern="/..*" 
        android:scheme="https" /> 
</intent-filter> 

我的問題是,當用戶打開一個鏈接,即「www.example。 com/somepage「,例如環聊,WhatsApp,Android應用選擇器不會在其列表中顯示可能的應用,它只顯示選項中的所有瀏覽器應用。但是當用戶在消息中輸入「https://www.example.com/somepage」後,Android會在App選擇器中顯示我的應用程序以打開鏈接。 它也不起作用當我嘗試從我的意圖過濾器中刪除android:scheme="https"

有沒有人有同樣的問題,並有解決方案?

任何幫助真的很感激。

回答

0

這是預期的行爲。

什麼下面的代碼片段確實是註冊您的應用程序作爲URL方案https://

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

這意味着你的應用程序將提供作爲任何關聯https://開始,包含www.example.com選項的處理程序。字符串www.example.com/somepage不符合條件,因爲它缺少https://部分。

您可以嘗試爲http://鏈接添加過濾器。我不確定Android是否會自動推斷爲沒有指定方案的Web鏈接方案,因此可能可以解決此問題。

<intent-filter android:autoVerify="true"> 
    <category android:name="android.intent.category.DEFAULT" /> 

    <action android:name="android.intent.action.VIEW" /> 

    <category android:name="android.intent.category.BROWSABLE" /> 

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

    <data 
     android:host="www.example.com" 
     android:pathPattern="/..*" 
     android:scheme="http" /> 
</intent-filter>