【问题标题】:Android app redirected to Custom Store instead of Google Play StoreAndroid 应用重定向到自定义商店而不是 Google Play 商店
【发布时间】:2017-01-11 19:56:31
【问题描述】:

这是一个基本代码,用于将您的用户从您的 Android 应用程序内部重定向到 Google Play Store,它在大多数设备上都按预期工作:

final String appPackageName = activity.getPackageName();
try {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName));
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    activity.startActivity(i);
} catch (android.content.ActivityNotFoundException anfe) {
    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

但是,在某些自定义 Android based OS(如 Mi UI)上,它将用户重定向到他们自己的自定义商店(即 Mi Store)而不是 Google Play Store。由于我的应用程序(我认为还有很多其他应用程序)没有在那些自定义商店中列出,用户可能会错误地认为该应用程序没有注册为官方应用程序或其他东西。

有什么方法可以让它检测到是否正确重定向到 Google Play 商店?

注意:我用来测试的手机安装了 Google Play 商店,但仍未重定向到它。

【问题讨论】:

  • 当自定义 UI 制造商使用与 Android 相同的 URL 方案来推广他们的应用程序商店时,就会发生这种情况。下面是问题的详细解决方案stackoverflow.com/a/28090925/1061944
  • 有些人可能认为它与this post 重复,但我认为它确实不是。由于链接的帖子仅要求(通常)从 Android 应用程序内部打开 Google Play,因此没有特别提及 ONLY Google Play 和任何其他市场商店。由于许多开发人员可能尚未在基于 Android 的定制操作系统上测试他们的应用程序,我认为如果这个问题得到一个好的答案,它将对他们中的很多人有所帮助
  • 然后在找到答案后发布您的答案。它将帮助其他搜索者。
  • 我还在寻找答案。我会在早上第一件事尝试你的链接答案。非常感谢@MurtazaKhursheedHussain

标签: android google-play


【解决方案1】:
Try this code:



final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

Hope this will help for you.

【讨论】:

  • 正如我在回答中提到的那样,我已经这样做了,并要求另一种方式。请先阅读。顺便说一句,欢迎来到 StackOverflow :)
  • 和问题码有什么区别?你至少读过这个问题吗?
猜你喜欢
  • 2016-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多