Android and Facebook: How to get picture of logged in User

前端 未结 7 1036
攒了一身酷
攒了一身酷 2020-12-08 06:30

I use the official Facebook SDK in my Android Application. After the user logs in, I can get the uid and the name of the facebook user like so:

Facebook mFac         


        
相关标签:
7条回答
  • 2020-12-08 06:59

    You can request a direct URl which contains your Access token:

    URL MyProfilePicURL = new URL("https://graph.facebook.com/me/picture?type=normal&method=GET&access_token="+ Access_token );
    

    Then get a decoded BitMap and assign it to image view:

    Bitmap MyprofPicBitMap = null;
    try {
        MyprofPicBitMap = BitmapFactory.decodeStream(MyProfilePicURL.openConnection().getInputStream());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    MyProfilePicImageView.setImageBitmap(mIcon1);
    
    0 讨论(0)
提交回复
热议问题