Android 深 link 总是先在浏览器中打开然后正确 activity

Android deep link always opening in the Browser first and then the correct activity

在 Android 版本 5.0 上,我们使用 Deep links,因为 App links 只能从 Android 6.0 开始工作。我们在这些设备上面临一个问题:当意图首先从主机应用程序启动时,link 在浏览器中打开,然后在短暂延迟(2-3 秒)后它启动目标应用程序,即使我们 select “始终在应用程序中打开”选项。我们可以做些什么来直接在应用程序中打开 link 而无需在浏览器中短暂打开?

    <activity android:name=".deeplinking.DeepLinkingNavigationActivity">
        <intent-filter android:priority="999”>
        <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="@string/deep_linking_host"
            android:pathPrefix="/authorize/" />
        </intent-filter>
    </activity>

实际上您自己回答正确 - 在 5.0 版 Android 中深入 link 的方法是通过 URI 方案或 Intents,两者都需要浏览器重定向才能做到这一点。因此,您将打开一个中间浏览器(这是不可避免的)。

请注意,不同的浏览器将需要不同的深度 linking 行为(URI 方案、意图,甚至根本不支持深度 linking)。