【问题标题】:Deeplink on click opens intent chooser in android点击时的深层链接在 android 中打开意图选择器
【发布时间】:2017-01-04 07:28:19
【问题描述】:

我已经为我的活动实施了深度链接。但是当点击链接时,会打开一个 Intent 选择器,询问是从应用程序还是从浏览器打开。如何直接从应用程序打开?

此外,当应用程序未安装时,它不会进入 Playstore。它在浏览器中打开。

以下是我在清单中的代码:

<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>

【问题讨论】:

标签: android deep-linking applinks deeplink


【解决方案1】:

这就是意图过滤器的工作方式。如果超过 1 个应用程序可以处理您的意图,它将显示一个意图选择器。是否要在您的应用或浏览器中打开链接取决于用户。

您的服务器应该处理 playstore 重定向部分。例如,您的深层链接网址是 http://www.example.com/page/1。现在,当未安装应用程序时,服务器可以检查是否从浏览器调用 url,然后它应该将浏览器重定向到 playstore 的应用程序 url。

【讨论】:

    【解决方案2】:

    @Eric B. 是对的。 即使您希望只有您的应用可以打开该链接,您也需要在 intent-filter 中使用自定义方案,例如:

    android:scheme="ddnews"
    

    并且需要建立链接,例如ddnews://domain.com/dir/page.html

    【讨论】:

    • 它不会作为链接,你有完整的例子说明它是如何工作的吗?
    • 请在 medium.com 上找到它:Custom URL Scheme
    猜你喜欢
    • 2020-09-09
    • 2019-05-19
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 1970-01-01
    相关资源
    最近更新 更多