首页 > 解决方案 > 如何从 URL 打开应用程序?

问题描述

我的目标是在用户单击链接时打开我的 android 应用程序,例如我已经共享了特定的项目链接(http://example.com/api_shirts.php?utmsource=shirt98)然后如果用户已经安装了我的应用程序然后打开它在其他地方打开它在浏览器上。

我已经搜索了很多并得到了这个,但它对我不起作用

       <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http"
                android:host="www.example.com" />
            <data android:scheme="https"
                android:host="www.example.com"/>
        </intent-filter>

标签: androidandroid-intent

解决方案


我不确定您是否需要在这种情况下设置 pathPrefix。此外,操作系统可能会打开用户已设置为该架构的默认应用程序的其他首选应用程序。

如果我没记错的话,您必须将您的应用程序与您的网站相关联,以便操作系统可以绕过用户的选择直接打开应用程序:

https://developer.android.com/studio/write/app-link-indexing.html#associatesite

另外,请查看https://developer.android.com/training/app-links/verify-site-associations.html以了解“深层链接”与“应用程序链接”。您需要应用链接来完成您正在尝试做的事情。


推荐阅读