I am trying to get user profile photo from Facebook using social-auth android library.
I am logged in successfully, I get user info after logged in onComplete of ResponseListener I get the user profile image url but when I set it to ImageView my ImageView get blank.
Here is my code.
mSocialAdapter = new SocialAuthAdapter(new ResponseListener());
mSocialAdapter.authorize(this,Provider.FACEBOOK);
private final class ResponseListener implements DialogListener{
@Override
public void onBack() {
}
@Override
public void onCancel() {
}
@Override
public void onComplete(Bundle bundle) {
mSocialAdapter.getUserProfileAsync(new SocialAuthListener<Profile>() {
@Override
public void onExecute(String arg0, Profile profile) {
if(profile.getDisplayName() != null)
Log.e("Display name", profile.getDisplayName());
if(profile.getProfileImageURL() != null){
Log.e("Profile Image Url", profile.getProfileImageURL());
Picasso.with(RegisterProfileSetupActivity.this).load(profile.getProfileImageURL()).into(imgUserPhoto);
//imgUserPhoto.setImageBitmap(loadImage(profile.getProfileImageURL()));
}
}
@Override
public void onError(SocialAuthError arg0) {
}
});
}
@Override
public void onError(SocialAuthError arg0) {
}
}
I also try this method to load Bitmap
public Bitmap loadImage(String url) {
DefaultHttpClient client = new DefaultHttpClient();
Bitmap bitmap = null;
try {
HttpResponse response = client.execute(new HttpGet(url));
HttpEntity entity = response.getEntity();
if(entity != null) {
InputStream in = entity.getContent();
bitmap = BitmapFactory.decodeStream(in);
}
}
catch (Exception e) {
}
return bitmap;
}