获取Gmail的轮廓图像和全名 [英] Get gmail profile image and full name
本文介绍了获取Gmail的轮廓图像和全名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是preparing一个登录页面,我的应用程序。我想要做同样的事情,Twitter的是做。他们正在帮助用户和predefining如电子邮件,姓名和个人资料PIC某些字段。我设法使用 GET_ACCOUNTS
许可获得的电子邮件。
不过,我不能看到我是如何得到的全名和用户照片?
公共静态字符串getEmail(上下文的背景下)
{
的AccountManager的AccountManager = AccountManager.get(上下文);
帐户帐户=是getAccount(的AccountManager);
如果(账号== NULL)
{
返回null;
}
其他
{
返回account.name;
}
}
私有静态账户是getAccount(的AccountManager的AccountManager)
{
帐户[]帐户= accountManager.getAccountsByType(com.google);
帐户帐户;
如果(accounts.length大于0)
{
账户=账户[0];
}
其他
{
账户= NULL;
}
返回帐户;
}
解决方案
您需要使用的 ContactsProvider 以实现这一目标。
I am preparing a login page for my app. I wanted to do the same thing that twitter is doing. They are helping the user and predefining some fields like email, name and profile pic. I managed to get the email using the GET_ACCOUNTS
permission.
However I cant see how I get the full name and profile pic?
public static String getEmail(Context context)
{
AccountManager accountManager = AccountManager.get(context);
Account account = getAccount(accountManager);
if (account == null)
{
return null;
}
else
{
return account.name;
}
}
private static Account getAccount(AccountManager accountManager)
{
Account[] accounts = accountManager.getAccountsByType("com.google");
Account account;
if (accounts.length > 0)
{
account = accounts[0];
}
else
{
account = null;
}
return account;
}
解决方案
You need to use ContactsProvider to achieve this.
这篇关于获取Gmail的轮廓图像和全名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文