点击深层链接可在Android中打开意图选择器 [英] Deeplink on click opens intent chooser in android

查看:150
本文介绍了点击深层链接可在Android中打开意图选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为自己的活动实现了深层链接。但是,单击链接后,将打开一个Intent选择器,询问是从应用程序还是从浏览器打开。如何直接从应用程序打开?

I have implemented deeplinking in one for my activities. But when the link is clicked, an Intent chooser opens asking whether to open from the app or from the browser. How to open from app directly?

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

Also, when the app is not installed, it does not take to playstore. It opens in the browser.

以下是清单中我的代码:

Below is my code in the manifest :

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


推荐答案

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

This is how intent filter work. If more than 1 app can handle your intent, it will show an intent chooser. It's up to the user whether they want to open the link in your app or browser.

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

Your server should handle the playstore redirection part. For example your deeplink url is http://www.example.com/page/1. Now when the app is not installed the server can check if the url is called from a browser, then it should redirect the browser to the playstore's app url.

这篇关于点击深层链接可在Android中打开意图选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆