0

我已经为我的活动实施了深度链接。但是当点击链接时,会打开一个 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>
4

2 回答 2

5

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

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

于 2017-01-04T07:39:49.893 回答
2

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

android:scheme="ddnews"

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

于 2017-01-04T08:27:08.070 回答