开始下载和安装 Android 应用程序(如果未安装应用程序)

Start Downloading and Installing Android App if app is not installed

我在清单

中通过这段代码使用深度 linking
<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>

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

在此我想实现两件事-

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

目前,当我键入 url 并单击 go.App 时,应用程序未打开 当我单击任何 link 网站时,应用程序正在打开 link。

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

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

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

  1. 方案是 https,它 doesn\t 与 http
  2. 一起使用
  3. 您必须输入有效 link 到市场

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

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

Open Directly : https://market.android.com/details?id=packagename

1.Enabling deep linking 上的 google 教程之后,他们提供了下一个示例

<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. At this moment I am able to transfer to play store when app is not

installed but downloading not started.

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