Java 如何使用毕加索显示URI中的图像?图像不显示
我试图让应用程序使用毕加索显示登录用户的个人资料图片,但个人资料图片没有显示由Java 如何使用毕加索显示URI中的图像?图像不显示,java,android,picasso,Java,Android,Picasso,我试图让应用程序使用毕加索显示登录用户的个人资料图片,但个人资料图片没有显示由个人资料生成的uri。getPhotoUrl()方法会显示,但当我尝试使用该url显示图像时,它不会显示。 我做了一些研究,发现它没有出现的原因是因为它是一个ContentProviderURI。 如何获取要显示的配置文件图片 是配置文件的uri的样子: if (user != null) { for (UserInfo profile : user.getProviderData()) { /
个人资料生成的uri。getPhotoUrl()方法会显示,但当我尝试使用该url显示图像时,它不会显示。
我做了一些研究,发现它没有出现的原因是因为它是一个ContentProviderURI。
如何获取要显示的配置文件图片
是配置文件的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);
};
}
或
或
从Uri获取路径并使用该路径创建文件对象
File file=new File(uri.getPath());
Picasso.with(getActivity()).load(file).into(imageView);
从Uri获取路径并使用该路径创建文件对象
File file=new File(uri.getPath());
Picasso.with(getActivity()).load(file).into(imageView);
这将不断用新图像替换旧图像。每次都使用相同的pic ImageView。如果问题出在Picasso
上,请使用callback
查看错误,这将继续用新图像替换旧图像。您每次都使用相同的pic ImageView。如果问题出在毕加索
File file=new File(uri.getPath());
Picasso.with(getActivity()).load(file).into(imageView);