如何获取非主要购买帐户电子邮件地址

发布于 2024-12-28 21:03:41 字数 344 浏览 0 评论 0原文

在推出 Android 3.0 之前,在手机上注册的第一个 com.google 帐户是主帐户,也是 Android Market 使用的唯一帐户。

在 Android 3.0 及更高版本的设备上,我不能再依赖此 (Account[0]) 来获取客户的电子邮件地址。

有没有办法知道哪个帐户 com.google 帐户当前正在进行购买?

(我需要的只是帐户类型 com.googleAccount[] 数组中的索引。一旦我有了相关索引)

Prior to the introduction of Android 3.0, the first com.google account registered on a phone was the primary account, and the only account used by Android Market.

On devices on Android 3.0 and up I can no longer rely on this (Account[0]) to get the customer's email address.

Is there a way to tell which account com.google account is currently making the purchase?

(all I need is the index into the Account[] array for account type com.google. I can get the email address once I have the relevant index)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

滿滿的愛 2025-01-04 21:03:41

恐怕这是不可能的。根据我的发现,进行应用内购买的帐户似乎是用于安装应用程序的帐户,而您不知道这一点。我想可能可以从 root 手机上的 Play 商店应用程序数据库中读取它。

看起来使用 Google Play Android Developer API,但不知道为什么会这样。

如果你万一发现了这一点,请告诉我。

I am afraid it's not possible. From what I've found it looks like that the account making the in-app-purchase is the account used to install the app, which you don't know. I guess it might be possible to read it from the Play store application database on rooted phones.

It looks like that it's not even possible to find the purchasing account after the purchase has been done using the Google Play Android Developer API, not sure why is that though.

If you, by any chance, find that out, let me know.

书信已泛黄 2025-01-04 21:03:41

我刚刚做了一个快速的谷歌搜索,并在这个网站上发现了这个

您可以使用 AccountManager.getAccountsAccountManager.getAccountsByType 获取设备上所有帐户名称的列表。幸运的是,对于某些帐户类型(包括 com.google),帐户名称是电子邮件地址。下面的示例片段。

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) {
    if (emailPattern.matcher(account.name).matches()) {
        String possibleEmail = account.name;
        ...
    } }

请注意,这需要 GET_ACCOUNTS 权限:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

有关使用 AccountManager 的更多信息,请访问 联系人管理器 SDK 中的示例代码。

I just did a quick google search and came across this on this site here.

You can use AccountManager.getAccounts or AccountManager.getAccountsByType to get a list of all account names on the device. Fortunately, for certain account types (including com.google), the account names are email addresses. Example snippet below.

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+ Account[] accounts = AccountManager.get(context).getAccounts(); for (Account account : accounts) {
    if (emailPattern.matcher(account.name).matches()) {
        String possibleEmail = account.name;
        ...
    } }

Note that this requires the GET_ACCOUNTS permission:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

More on using AccountManager can be found at the Contact Manager sample code in the SDK.

墨落画卷 2025-01-04 21:03:41

名字和姓氏 >> java代码?

电子邮件添加代码

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
    if (account.type.equals("com.google")) {
        email = account.name.toString();
        break;
    } else if (emailPattern.matcher(account.name).matches()) {
        email = account.name.toString();
    }
}

firs name and last name >> java code ?

email add code

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(getApplicationContext()).getAccounts();
for (Account account : accounts) {
    if (account.type.equals("com.google")) {
        email = account.name.toString();
        break;
    } else if (emailPattern.matcher(account.name).matches()) {
        email = account.name.toString();
    }
}
南渊 2025-01-04 21:03:41
import android.provider.ContactsContract;

AccountManager am = AccountManager.get(this);
Account[] accounts = am.getAccountsByType("com.google");        

//you can set current sync account..

boolean syncEnabled = ContentResolver.getSyncAutomatically(accounts[0], ContactsContract.AUTHORITY);
import android.provider.ContactsContract;

AccountManager am = AccountManager.get(this);
Account[] accounts = am.getAccountsByType("com.google");        

//you can set current sync account..

boolean syncEnabled = ContentResolver.getSyncAutomatically(accounts[0], ContactsContract.AUTHORITY);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文