如何获得的第一个Gmail帐户的细节,当我们转换我们的手机并注册 [英] How to get the First Gmail account detail when we switch ON our phone and register it

查看:211
本文介绍了如何获得的第一个Gmail帐户的细节,当我们转换我们的手机并注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code,它是让所有的都与我的手机同步的Gmail ID的,但我想在Gmail主ID用户注册的第一次。因为所有其他的Gmail账户(不是主要的),如果我想我可以删除任何时间,但删除主帐户,我们必须做其他的东西太多,所以这就是为什么我想要得到的主帐号使用到我的应用程序。

I have the following code that is getting all the gmail id's that are synchronized with my phone but i want the Main gmail id that user register the first time. Because all the other gmail accounts(not main) if i want i can delete anytime but to delete the main account we have to done other things too, So that's why i want to get the main account to use into my application.

这是我的codeI想添加一些过滤器在里面,我能做到这一点,但能不能正确地得到的东西。

here's my code i think to add some filter in it, i can do that but can't able to get the thing correctly.

Account[] accounts=AccountManager.get(this).getAccountsByType("com.google");
    for(Account account: accounts)
    {
        String possibleEmail=account.name;
        Log.d("Possible email id's of user", possibleEmail);
    }

我已经看到了<一个href="http://stackoverflow.com/questions/2112965/how-to-get-the-android-devices-primary-e-mail-address">Roman链接但没有能够将其转换以正确的方式。 我想用C2DM从谷歌使用这个主电子邮件ID为推送通知。

i already seen Roman link but didn't able to convert it in right manner. I want to use this main email id for push notification using C2DM from google.

推荐答案

我有一个答案,但它不是做一个正确的做法。由于我收到的所有与谷歌(Gmail的)相关联的账户,当我们进入电子邮件ID的要与Gmail的堆栈中创建和0号位置,我得到的主要Gmail的ID最早是由用户输入同步时,他接通他的电话。

I have an answer, but it was not a correct way to do it. As i am getting all the accounts associated with google(gmail) and as we enter the email id's to be synchronized with gmail a stack is created and on 0th position, I am getting the primary Gmail id that was first enter by the user when he switched ON his phone.

    Account[] accounts=AccountManager.get(this).getAccountsByType("com.google");
    String myEmailid=accounts[0].toString();
    Log.d("My email id that i want", myEmailid);
    for(Account account: accounts)
    {
        String possibleEmail=account.toString();
        Log.d("Possible email id of user", possibleEmail);

    }

如果有人有一个更好的解决方案,然后让我知道,我测试了2手机这个例子中,它工作正常,但我看到的是获取用户的主电子邮件ID发送电子邮件许多应用程序和所有的,我想知道他们是如何做的?

If someone has a better solution then let me know, i tested this example on 2 phones and it works fine, but i see many applications that are fetching the primary email id of users to send email and all, i want to know how they are doing?

这篇关于如何获得的第一个Gmail帐户的细节,当我们转换我们的手机并注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆