2017-02-13 1 views
1

konnte ich das Foto URI mit diesem Code aus dem Feuerbasis doc bekommenFirebase Google Anmelden - Foto URI

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); 
if (user != null) { 
    for (UserInfo profile : user.getProviderData()) { 
     // Id of the provider (ex: google.com) 
     String providerId = profile.getProviderId(); 

     // UID specific to the provider 
     String uid = profile.getUid(); 

     // Name, email address, and profile photo Url 
     String name = profile.getDisplayName(); 
     String email = profile.getEmail(); 
     Uri photoUrl = profile.getPhotoUrl(); 
    }; 
} 

Ich habe auch ein Image mpic genannt und ich versuchte, diesen Code.

mPic.setImageURI(null); 
mPic.setImageURI(photoUrl); 

Leider kann ich das Foto nicht anzeigen. Irgendwelche Tipps, wie man das macht?

+0

Haben Sie photoUrl Wert ausdrucken? Ist es http URL? – steve

+0

ist es ein https URL –

Antwort

3

Versuchen Sie die Picasso-Bibliothek zu verwenden. http://square.github.io/picasso/

Picasso.with(context) 
      .load(url) 
      .placeholder(R.drawable.placeholder) 
      .resize(imgWidth, imgHeight) 
      .centerCrop() 
      .into(image); 
+0

ich verstehe nicht die Parameter Kontext und Bild –

+0

Kontext ist für Aktivität oder Fragment, die Sie arbeiten. image ist für imageview in ihrem fall, es wird mPic sein. – steve

+0

danke. es funktioniert :) –

1
Picasso.with(getApplicationContext()) 
         .load(mAuth.getCurrentUser().getPhotoUrl()) 
         .resize(50, 50) 
         .centerCrop() 
         .into(yourImageView);