java - 如何使用picasso显示来自URI的图像?图像不显示

标签 java android picasso

我试图让应用程序使用 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/

相关文章:

java - owasp zap如何检查post请求的漏洞

java - Tomcat + OpenSSL 符号查找报错 undefined symbol EC_KEY_new_by_curve_name

java - session 超时java

android - 在 android 中的谷歌地图上设置缩放级别

android - 从服务器下载图像到 ImageView 时显示进度

Java 堆空间不足

android - 旋转回纵向时避免 Android VideoView 损坏

android - 在 android 中使用 Google Url Shortener Api 时出现解析错误

android - 首次运行时未加载 picasso 图像

Android Image Picasso Square缓存大小