Android 短信 link 到应用程序或 Google 播放

Android sms with link to application or Google play

我正在尝试创建一个应用程序,它将使用 link 发送短信到以下地址: 如果 phone 上已经安装了应用程序,link 将打开它。 如果未安装该应用程序,link 将在应用程序页面上打开 Google Play 商店...

例如:您的 link 将类似于 https://example.com 并且您在 Android 清单中具有意图过滤器,如下所示:

<activity
    android:name="com.droid.MainActivity"
    android:label="@string/app_name" >

    <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="example.com"
            android:scheme="https" />
    </intent-filter>
</activity>

使用 URL 映射 编辑器通过 Android 应用程序链接(Android Studio > 工具 > Android 应用程序链接)。

为您的应用程序网站 Url 提供 SMS。

在那个页面重定向到 Playstore。

在您的应用程序中用您的 URL

创建 DeepLink

每当遇到 URL 时,如果安装了应用程序,就会打开该应用程序。否则,它将从页面重定向到 Play 商店。

您可以使用 App 的 Playstore Url。但不推荐,因为 playstore 和其他商店应用程序也可能捕获相同的 link.

DeepLinking In Android Application

例子

<activity
    android:name="com.package.MainActivity"
    android:label="@string/app_name" >

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="weburl"
            android:scheme="https" />
    </intent-filter>
</activity>