dwarvesf / til

Today I Learned. Our knowledge hub. List out what we've learned everyday, organized.
29 stars 1 forks source link

Problem when cannot load facebook profile image on android #46

Open siliconprime-thanhduc opened 5 years ago

siliconprime-thanhduc commented 5 years ago

When Khanh implement Welcome Back UI on Sol, he needs to load facebook profile image onto ImageView.

He has a problem when we use Glide to load this URL, Glide cannot load it, and if you click this link by browser, it's will download this image and don't show anything. It'so weird, because it just a link to show an image.

So after reviewing the code, we easy to fix it with type one word. http change to https

eg: http://graph.facebook.com/2536187389726079/picture?type=large to https://graph.facebook.com/2536187389726079/picture?type=large

It easy, right?

Another way to load the facebook profile image onto view:

We will use ProfilePictureView ( widget of Facebook SDK)

<com.facebook.login.widget.ProfilePictureView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    facebook:preset_size="small"/>

After that, you can set facebook id like this in code

profilePictureView.setProfileId(facebookUserId);