I am trying to display the Facebook profile image using Glide in an ImageView once the user logs in, the problem is that Glide only loads the default image from Facebook, I have tried different ways but it always loads the same image by default.
This is the image that Glide shows
Here is my code:
onCreate method:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container, false);
if (AccessToken.getCurrentAccessToken() == null){
goLoginScreen();
}else {
Profile profile = Profile.getCurrentProfile();
if (profile != null){
displayProfileInfo(profile);
}else{
Profile.fetchProfileForCurrentAccessToken();
}
}
return view;
}
displayProfileInfo method:
private void displayProfileInfo(Profile profile){
String name = profile.getName();
String photoUrl = profile.getProfilePictureUri(100,100).toString();
txtviewUname.setText(name);
Glide.with(getActivity()).load(photoUrl).into(profileImage);
}
2
Answers
Use context, for exemple
or
, if it is in Activity use only
Glide use Context
According to your comment:
This means that the getPhotoUrl() method that exists in the FirebaseUser class, returns an URL that points to a valid photo. However, that photo is added automatically by Facebook when the users decide not to add any photos to the profile. So if a user doesn’t have any photos, the default photo will always be displayed. So when you try to read the photo that is associated to such an account, the default photo will be displayed.