我试图让应用程序使用 picasso 显示登录用户的个人资料图片,但个人资料图片不显示由 profile.getPhotoUrl()
方法生成的 uri,但当我尝试使用该 url 来显示图像时,它不显示。
我做了一些研究,发现它没有显示的原因是因为它是一个 contentProvider uri。
如何才能显示个人资料图片?
Here配置文件的 uri 是这样的:
if (user != null) {
for (UserInfo profile : user.getProviderData()) {
// Id of the provider (ex: google.com)
String providerId = profile.getProviderId();
// this displays the email for some reason
String uid = profile.getUid();
//displays the name
String name = profile.getDisplayName();
//doesnt even display the email for some reason
String email = profile.getEmail();
//profile pic uri
Uri photoUrl = profile.getPhotoUrl();
displayUser.setText(uid);
displayName.setText(name);
displayPhotoUrl.setText(photoUrl.toString());
Picasso.with(getApplicationContext())
.load(photoUrl)
.into(pic);
};
}
最佳答案
Picasso.with(getActivity()).load(uri).into(imageView);
或者
File f = new File(uri);
Picasso.with(getActivity()).load(f).into(imageView);
关于java - 如何使用picasso显示来自URI的图像?图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46870882/