[英]How to get the profile and cover picture from gmail account on android programmatically
Actually, I am developing an app with a navigation drawer . 实际上,我正在开发一个带有导航抽屉的应用程序。 So, I need one profile picture and one background picture to make it charming. 因此,我需要一张个人资料图片和一张背景图片来使其变得迷人。 Google account is best in this case at least in my eyesight. 在我看来,至少在这种情况下,最好使用Google帐户。 So, I need to get the profile picture and cover picture from primary gmail account of an android device. 因此,我需要从android设备的主要gmail帐户中获取个人资料图片和封面图片。 Can anyone help me please? 谁能帮我吗? I'll be very much helped after all.. 毕竟,我会给您很大的帮助。
Use Google Android API to integrate Sign-in of primary gmail account into your app. 使用Google Android API将主要gmail帐户的登录功能集成到您的应用中。 Refer the official google sign-in documentation Google Sign-In for Android 请参阅官方的Google登录文档Google Android登录
After following the above documentation, you can get the profile information(display name and profile image) by belowed code : 遵循上述文档后,您可以通过以下代码获取配置文件信息(显示名称和配置文件图像):
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); GoogleSignInAccount acct = result.getSignInAccount(); String personName = acct.getDisplayName(); String personEmail = acct.getEmail(); String personId = acct.getId(); Uri personPhoto = acct.getPhotoUrl();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.