深层链接无法正常工作

Deeplink didn't work properly

创建深度link 表单 android 工作室,我将 assetlinks.json 文件上传到主机上我的 .well-known 文件夹中。

在 android studio deep link 构建工具上一切正常,但是当我在我的网站上单击 link 时,它不会打开应用程序。 我的深度 link 配置是这样的:

<activity
       android:name=".activities.OrdersActivity"
       android:screenOrientation="portrait">
       <tools:validation testUrl="https://myhost.com/cart/success" />

       <intent-filter android:autoVerify="true">
           <action android:name="android.intent.action.VIEW" />

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

           <data
               android:scheme="https"
               android:host="myhost.com"
               android:pathPrefix="/cart/success" />
       </intent-filter>
   </activity>

我试过的url是这个

https://myhost.com/cart/success?Authority=000000000000000000000000000000074139&Status=OK

您的代码看起来不错。您在哪个应用程序中单击了 link?他们可能会阻止 deeplinks 并使用 custom tabs library?

在他们的应用程序中打开它们

您可以通过执行下面的 adb shell 命令来尝试您的 deeplinks:

am start -a android.intent.action.VIEW -d "https://myhost.com/cart/success?Authority=000000000000000000000000000000074139&Status=OK"

您无需将 assetlinks.json 文件上传到您的 .wellknown 文件夹即可实施 deeplinks。 applinks 需要它。 applink 和 deeplink 之间的区别是,deeplinking 需要用户批准才能启动您的应用,而 applinking 会自动启动。

更详细的解释见下文

https://developer.android.com/training/app-links/