[英]How to use picasso to display image from URI? image does not show up
我正在尝试让应用程序使用毕加索显示已登录用户的个人资料图片,但个人资料图片未显示由profile.getPhotoUrl()
方法生成的uri,但当我尝试使用该网址显示图片未显示。
我做了一些研究,发现它之所以没有显示是因为它是一个contentProvider uri。
如何显示个人资料图片?
以下是个人资料的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);
从Uri获取路径,并使用该路径创建文件对象。
File file=new File(uri.getPath());
Picasso.with(getActivity()).load(file).into(imageView);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.