【问题标题】:Start Downloading and Installing Android App if app is not installed如果未安装应用程序,请开始下载和安装 Android 应用程序
【发布时间】:2015-10-05 07:16:18
【问题描述】:

我在清单中通过此代码使用深层链接

<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:host="abc.in"
        android:pathPrefix="/"
        android:scheme="https" />
</intent-filter>

点击网页上的链接安装应用程序时,它对我的​​应用程序开放。

在此我想实现两件事-

  1. 当我输入 url 并点击 Go 时打开我的应用程序。

目前,当我输入 url 并单击 go 时,应用程序未打开。当我单击网站任何链接时,应用程序正在打开。

  1. 如果未安装应用,我想开始下载应用。

此时我可以在未安装应用但未开始下载的情况下转移到 Play 商店。

如果这些事情可以完成,我需要你的帮助

【问题讨论】:

    标签: android intentfilter


    【解决方案1】:

    1.按照Enabling deep linking 上的谷歌教程,他们提供了下一个示例

    <activity
        android:name="com.example.android.GizmosActivity"
        android:label="@string/title_gizmos" >
        <intent-filter android:label="@string/filter_title_viewgizmos">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
            <data android:scheme="http"
                  android:host="www.example.com"
                  android:pathPrefix="/gizmos" />
            <!-- note that the leading "/" is required for pathPrefix-->
            <!-- Accepts URIs that begin with "example://gizmos”
            <data android:scheme="example"
                  android:host="gizmos" />
            -->
        </intent-filter>
    </activity>
    

    另请注意,从 Android 11 开始,有一个安全更新,您需要至少启动一次您的应用程序才能使用深层链接。

    1. 此时我可以在应用不可用时转移到 Play 商店

    已安装但未开始下载。

    这是您将获得的最好的,唯一可以自动开始下载的地方是从 Play 商店,他们希望保持这种状态;)

    【讨论】:

    • 你的意思是不能自动开始下载
    • @AshishAgrawal 是的。不是来自 Play 商店。
    • 好的,但我的另一个问题是,当我在浏览器中打开链接时,第一次应用程序没有打开。当我的网站打开并且我点击我网站中的某个位置时,我的应用程序被打开了。我可以打开应用程序吗在开始输入 url 并按下 go
    • @AshishAgrawal 是的,这是出于安全考虑,请参阅我对答案的更新。
    【解决方案2】:
    1. 方案是 https,它不适用于 http
    2. 您必须输入有效的市场链接

    例如从 Google Play 中的网站打开应用程序:

    搜索: https://market.android.com/search?q=pname:packagename

    直接打开: https://market.android.com/details?id=packagename

    【讨论】:

    • 这是有效的,但如果未安装应用程序,我想开始安装。你说的是什么类型的有效市场链接
    • 通过手机、市场、网站链接市场观看,
    • 请帮帮我,我没有得到我必须这样做
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 2013-07-01
    相关资源
    最近更新 更多