android - 与应用程序安装关联的帐户信息

标签 android in-app-purchase in-app-billing google-account android-billing

如何处理多个帐户是在 Android 中实现应用内计费的人们普遍关注的问题。如果用户配置了多个帐户,哪一个将用于应用内计费(因为没有让用户选择帐户的选项)?挖了很多之后,下面一段here似乎可以解释它..

Note: To make test purchases, the license test account must be on the user’s Android device. If the device has more than one account, the purchase will be made with the account that downloaded the app. If none of the accounts has downloaded the app, the purchase is made with the first account.Users can confirm the account that is making a purchase by expanding the purchase dialog.

我使用与应用计费相关的帐户创建开发者有效负载,以便以后可以在某个时间点或在其他设备上正确恢复。但是自从Honeycomb之后,就没有Primary Account这种东西了。用户可以删除任何帐户,可能是购买应用程序的帐户,在这种情况下,帐户列表中的第一个帐户将用于计费。现在,如果我知道使用了哪个帐户并且它恰好是“不是安装应用程序的帐户”,我至少可以通知用户以后不会恢复以下购买。

所以,我的问题是..

有没有办法找到用于下载应用程序的帐户?

Google Play 似乎确实使用了这些信息。无论如何,我们可以与 Google Play 交互到这个级别?

注意:PackageManager 似乎没有处理这个问题。

最佳答案

如果您想获取当前配置为播放商店帐户的帐户邮件ID的名称。请使用它。 我在这里仅用于电子邮件名称,但您可以从帐户对象中获取帐户的所有信息,例如类型,描述

  Pattern emailPattern = Patterns.EMAIL_ADDRESS; 
            Account[] accounts =        AccountManager.get(this).getAccountsByType("com.google");
            for (Account account : accounts) {
                if (emailPattern.matcher(account.name).matches()) {
                    primaryEmailID = account.name;

                }
            }

关于android - 与应用程序安装关联的帐户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19275246/

相关文章:

android - 如何在不签名的情况下创建 apk 版本

ios - 如何处理Apple App Store "Limited time only"内购?

安卓 : in-app Billing problem- getting the order Id from the response

java - Android .xml 文件,添加时项目不可见

android - Connectivity Manager 始终检测到有 Internet 连接

android - 有没有办法用我的 Json 数据设置可绘制文件夹中的图像,该数据包括可绘制文件夹中图像的名称

ios - Stripe 能否代替 Google IAB 用于多平台应用程序?

xcode - 确定是否正在使用 Xcode StoreKit 配置文件

ios - 恢复购买功能 - Swift

Android 应用内结算 "Un-purchase"用于测试?