Android Firebase Google登录-照片URI
我能够使用这个代码从firebase文档中获取照片URIAndroid Firebase Google登录-照片URI,android,firebase-authentication,google-signin,Android,Firebase Authentication,Google Signin,我能够使用这个代码从firebase文档中获取照片URI FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user != null) { for (UserInfo profile : user.getProviderData()) { // Id of the provider (ex: google.com) String providerId = profile
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
for (UserInfo profile : user.getProviderData()) {
// Id of the provider (ex: google.com)
String providerId = profile.getProviderId();
// UID specific to the provider
String uid = profile.getUid();
// Name, email address, and profile photo Url
String name = profile.getDisplayName();
String email = profile.getEmail();
Uri photoUrl = profile.getPhotoUrl();
};
}
我还有一个名为mPic的ImageView,我尝试了这段代码
mPic.setImageURI(null);
mPic.setImageURI(photoUrl);
不幸的是,我看不到这张照片。有什么建议吗?尝试使用毕加索图书馆
你打印了photoUrl值了吗?它是http url吗?它是https url我不理解参数上下文和imagecontext是用于您正在处理的活动或片段的。图像是针对imageview的,在您的情况下,它将是mPic。不过,最后一个问题是,如何将图像做成圆形?没问题。你能试试这个吗?毕加索.with(context).load(url).transform(new circlettransform()).into(image);CircletTransform()有错误。无法解析为符号
Picasso.with(context)
.load(url)
.placeholder(R.drawable.placeholder)
.resize(imgWidth, imgHeight)
.centerCrop()
.into(image);
Picasso.with(getApplicationContext())
.load(mAuth.getCurrentUser().getPhotoUrl())
.resize(50, 50)
.centerCrop()
.into(yourImageView);