PAYATHON 2026

如何将用户重定向到 Play Store 的 Subscription 页面

数据阿明

结论

可以使用 ACTION_VIEW 打开 Google Play 的订阅管理页面,建议使用以下 HTTPS 地址:

https://play.google.com/store/account/subscriptions

如果已知订阅商品 ID 和应用包名,可以直接打开该应用中特定订阅的管理页面:

https://play.google.com/store/account/subscriptions?sku=SUBSCRIPTION_ID&package=PACKAGE_NAME

Google Play Billing 不支持应用直接替用户取消订阅。通常的做法是将用户引导至订阅管理页面,由用户自行操作。

打开全部订阅列表

Intent intent = new Intent(
        Intent.ACTION_VIEW,
        Uri.parse("https://play.google.com/store/account/subscriptions")
);

try {
    startActivity(intent);
} catch (ActivityNotFoundException e) {
    // 设备上没有能够处理该链接的应用
}

该地址会显示当前 Google 账号下由 Google Play 管理的订阅。根据设备环境和系统的链接处理设置,页面可能在 Play Store 应用中打开,也可能在浏览器中打开。

打开指定订阅

如果要让用户直接进入某个订阅的管理页面,可以同时传入订阅商品 ID 和应用包名:

String subscriptionId = "premium_monthly";
String packageName = getPackageName();

Uri uri = Uri.parse("https://play.google.com/store/account/subscriptions")
        .buildUpon()
        .appendQueryParameter("sku", subscriptionId)
        .appendQueryParameter("package", packageName)
        .build();

Intent intent = new Intent(Intent.ACTION_VIEW, uri);

try {
    startActivity(intent);
} catch (ActivityNotFoundException e) {
    // 可在这里提示用户手动打开 Google Play 管理订阅
}

参数含义如下:

  • sku 是在 Google Play Console 中配置的订阅商品 ID。
  • package 是发布该订阅的应用包名,例如 com.example.app。
  • 这里应传入用户实际购买的订阅商品 ID,不能使用基础方案 ID、优惠 ID 或本地展示名称。

Kotlin 写法如下:

val subscriptionId = "premium_monthly"

val uri = Uri.parse("https://play.google.com/store/account/subscriptions")
    .buildUpon()
    .appendQueryParameter("sku", subscriptionId)
    .appendQueryParameter("package", packageName)
    .build()

val intent = Intent(Intent.ACTION_VIEW, uri)

try {
    startActivity(intent)
} catch (e: ActivityNotFoundException) {
    // 提示用户手动前往 Google Play 管理订阅
}

注意事项

用户必须登录购买该订阅时使用的 Google 账号。如果当前登录的账号不正确,页面可能提示找不到订阅。

使用时还需注意:

  • 部分非 GMS 设备可能没有安装 Google Play Store。
  • 如果订阅并非通过 Google Play 购买,就无法在 Google Play 中管理。
  • 对于已取消、已过期或处于特殊状态的订阅,页面的展示方式可能不同。
  • 打开链接并不表示订阅已经取消。用户返回应用后,应通过 Google Play Billing 查询购买状态,并由后端验证最新的订阅权益。
  • 如果无法确定用户购买了哪个订阅商品,可以打开不带参数的订阅列表页面,让用户自行选择。

备注:内容仅供参考。