[英]android-app link not working
我正在關注 Google I/O 2015 中的這個示例。
演示網站: http://recipe-app.com/recipe/grilled-potato-salad演示應用: http://search-codelabs.appspot.com/codelabs/android-deep-linking
我的測試:
我已經從上面的鏈接安裝了演示應用程序。 我使用谷歌搜索應用程序對“烤土豆沙拉”進行了谷歌搜索,發現http://recipe-app.com/recipe/grilled-potato-salad 。
我希望單擊鏈接會直接打開應用程序,而不是消歧對話框( http://search-codelabs.appspot.com/img/android-deep-linking/img-5.png )。 但是,消歧對話框仍然讓我感到驚訝。
那網站上的<link rel="alternate" href="android-app://com.recipe_app/http/recipe-app.com/recipe/grilled-potato-salad" />
不是沒用嗎?
應用的清單文件:
```
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >
<activity
android:name=".client.HomeActivity"
android:label="@string/app_name"
android:exported="true"
android:theme="@android:style/Theme.Holo.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".client.RecipeActivity"
android:label="@string/app_name"
android:exported="true"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Holo.NoActionBar">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://recipe-app.com/recipe" -->
<data android:scheme="http"
android:host="recipe-app.com"
android:pathPrefix="/recipe" />
</intent-filter>
</activity>
<provider
android:name=".client.content_provider.RecipeContentProvider"
android:authorities="com.recipe_app" >
</provider>
</application>
```
那個教程確實已經過時了。
HTML 標記確實沒用。
Google 搜索結果與深層鏈接一起使用所需要的是按照此處的說明在您的生產網絡服務器上有一個公開的https://<yoursite>/.well-known/assetlinks.json
文件:
為您的應用程序設置 URL 支持后,應用程序鏈接助手會生成一個數字資產鏈接文件,您可以使用它來將您的網站與您的應用程序相關聯。
作為使用數字資產鏈接文件的替代方法,您可以在 Search Console 中關聯您的網站和應用。
要使用 App Links Assistant 關聯您的 App 和您的網站,請單擊 App Links Assistant 中的 Open the Digital Asset Links File Generator,然后按照以下步驟操作:
App Links Assistant 將引導您完成基本的 URL 映射 圖 2. 輸入有關您的站點和應用程序的詳細信息以生成數字資產鏈接文件。
輸入您的站點域和您的應用程序 ID。 2) 要在您的數字資產鏈接文件中包含對密碼 Smart Lock 的支持,請選擇支持在應用程序和網站之間共享憑據並輸入您網站的登錄 URL。 這會將以下字符串添加到您的數字資產鏈接文件,聲明您的應用程序和網站共享登錄憑據:delegate_permission/common.get_login_creds。 詳細了解如何在您的應用中支持 Smart Lock for Passwords。 3) 指定簽名配置或選擇一個密鑰庫文件。 確保為應用程序的發布版本或調試版本選擇正確的配置或密鑰庫文件。 如果要設置生產版本,請使用發布配置。 如果要測試構建,請使用調試配置。 4) 單擊生成數字資產鏈接文件。 5) Android Studio 生成文件后,單擊“保存文件”進行下載。 6) 將 assetlinks.json 文件上傳到您的站點,每個人都具有讀取權限,位於 https:///.well-known/assetlinks.json。 重要提示:系統通過加密的 HTTPS 協議驗證數字資產鏈接文件。 確保 assetlinks.json 文件可通過 HTTPS 連接訪問,無論您的應用程序的 Intent 過濾器是否包含 https。
單擊鏈接並驗證以確認您已將正確的數字資產鏈接文件上傳到正確的位置。
您現在應該能夠看到您的應用 -已安裝在 Google 搜索結果中,這就是您知道它已運行的方式
嘗試使用
<intent-filter tools:node="merge" android:autoVerify="true">
Intent-filter 標簽中的 autoverify 告訴 Android 檢查網站和應用程序是否具有相同的公共所有者,這是應用程序鏈接所必需的(否則,它只是深層鏈接,這就是您看到消歧對話的原因)。
<intent-filter android:label="@string/app_name" android:autoVerify="true" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://recipe-app.com/recipe" -->
<data android:scheme="http"
android:host="recipe-app.com"
android:pathPrefix="/recipe" />
</intent-filter>
現在,嘗試先在您設備的“默認瀏覽器”上打開鏈接,默認瀏覽器通常是 Google 搜索。 有時,由於不同的原因,應用程序鏈接可能無法在 Chrome 或其他一些應用程序中使用。
如果您已經熟悉深度鏈接,您還可以參考此鏈接https://developer.android.com/training/app-links/了解如何讓您的網站 url 重定向到用戶手機上的應用程序(如果它已安裝。如果沒有,請參閱“Instant Apps-Android”)。
如果您已成功集成所有步驟並且您的鏈接已驗證連接到您的活動但仍未觸發應用程序的活動,則 go 到應用程序的設置並啟用深度鏈接,然后 select 您提供的鏈接。 一旦您在 Play 商店中更新發布版本,這將自動啟用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.