2017-01-04 47 views
0

我已經在我的活動中實現了一個深度鏈接。但是當鏈接被點擊時,一個Intent選擇器打開,詢問是從應用程序還是從瀏覽器打開。如何直接從應用程序打開?點擊深度鏈接打開Android中的意圖選擇器

此外,當應用程序未安裝,它不需要存儲。它在瀏覽器中打開。

下面是我在清單代碼:

<activity android:name=".activities.VideoNewsDetailActivity" 
     android:theme="@style/AppThemeActivity" 
     android:configChanges="orientation|screenSize" 
     > 
     <!-- Add this new section to your Activity --> 
     <intent-filter android:label="@string/videoNewsDetail"> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <!-- Handle urls starting with "http://www.example.com/products" --> 
      <data android:scheme="http" 
       android:host="ddnews.apprikart.in" 
       android:pathPrefix="/videos" /> 
      <!-- Handle local urls starting with "example://products" --> 
      <data android:scheme="ddnews.apprikart" 
       android:host="videos" /> 

     </intent-filter> 
    </activity> 
+0

這也可以幫助https://開頭developers.google.com/digital-asset-links/v1/getting-started – Tasneem

回答

4

這是怎麼意圖過濾器的工作。如果超過1個應用可以處理您的意圖,它會顯示一個意向選擇器。用戶是否想要在您的應用或瀏覽器中打開鏈接取決於用戶。

您的服務器應該處理playstore重定向部分。例如,您的深層鏈接網址是http://www.example.com/page/1。現在,當應用程序未安裝時,服務器可以檢查是否從瀏覽器調用URL,然後將瀏覽器重定向到Play Store的應用程序URL。

2

@Eric B.是對的。 即使你只想要你的應用程序可以打開該鏈接,那麼你需要使用自定義方案intent-filter,如:

android:scheme="ddnews" 

,需要建立類似的鏈接,ddnews://domain.com/dir/page.html