Get contacts photo which are synced with facebook for android

后端 未结 5 701
囚心锁ツ
囚心锁ツ 2020-12-25 09:56

I am trying to show contact pictures in my application but I am getting pictures of those who were added manually only and not those which are synced with facebook. How to w

5条回答
  •  醉梦人生
    2020-12-25 10:51

    It doesn't work for contacts that are synced from FB only. You'll need to use the FB graph API and fetch the photo from there; and you need to know the contacts facebook name.

     Bitmap contactPhoto = getImageBitmap("http://graph.facebook.com/mathiaslin/picture?type=square");
    
     final private static Bitmap getImageBitmap(String url) {
        Bitmap bm = null;
        try {
            URLConnection conn = new URL(url).openConnection();
            conn.connect();
            InputStream is = conn.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            bm = BitmapFactory.decodeStream(bis);
            bis.close();
            is.close();
        } catch (IOException e) {
            Log.e(TAG, "Error getting bitmap", e);
        }
        return bm;
    }
    

提交回复
热议问题