Oscarina
Oscarina

Reputation: 768

FirebaseUser image to ImageView

I'm working on Android Studio trying to display the image from a FirebaseUser that I get from login with Google into an imageview.

private void setUserData(FirebaseUser user) {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    View cabecera = navigationView.getHeaderView(0);

    TextView titulo = (TextView) cabecera.findViewById(R.id.titulo_cabecera);
    titulo.setText(user.getDisplayName());

    TextView mail = (TextView) cabecera.findViewById(R.id.mail_cabecera);
    mail.setText(user.getEmail());

    ImageView foto = (ImageView) cabecera.findViewById(R.id.imagen_cabecera);
    foto.setImageURI(user.getPhotoUrl());

}

Both textviews are displayed properly, but when I get to the imageview, I get this error:

E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: https:/lh3.googleusercontent.com/-DWsn6ecRPm0/AAAAAAAAAAI/AAAAAAAAAGk/K9bdBjTZO0Y/s96-c/photo.jpg: open failed: ENOENT (No such file or directory)

I/System.out: resolveUri failed on bad bitmap uri: https://lh3.googleusercontent.com/-DWsn6ecRPm0/AAAAAAAAAAI/AAAAAAAAAGk/K9bdBjTZO0Y/s96-c/photo.jpg

and show nothing on the imageview, if I go to the link with chrome it shows the image, is there something I'm missing or doing wrong?

Upvotes: 4

Views: 1604

Answers (1)

Bogdan Ustyak
Bogdan Ustyak

Reputation: 5837

For loading image from network try to use this library http://square.github.io/picasso/

This is an example:

Picasso.with(context).load(user.getPhotoUrl()).into(foto);

Upvotes: 4

Related Questions