0

I have an android game which users can login with facebook and play with their facebook friends. I am seeing a lot of comments about missing facebook profile pictures.

The below code does not work anymore. BitmapFactory.decodeStream returns null. I am sure the url is correct, because till yesterday the app could display facebook profile pictures. What could have been changed?

Thanks.

public static Bitmap getBitmapFromURL(String src) { try { URL url = new URL(src); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); InputStream input = connection.getInputStream(); Bitmap myBitmap = BitmapFactory.decodeStream(input); return myBitmap; } catch (IOException e) { Gdx.app.log(TAG, "Failed to download image from " + src, e); return null; } }

ilkinulas
  • 3,515
  • 3
  • 22
  • 29

1 Answers1

0

I had the same problem. It suddenly stopped working.. You can find a solution here:

Getting null bitmap while trying to get Facebook image using Facebook ID

Community
  • 1
  • 1
Rony Tesler
  • 1,207
  • 15
  • 25
  • I've switched to DefaultHttpClient and profile pictures are visible. But i am trying to understand what has changed? – ilkinulas Mar 28 '14 at 14:59
  • I think it's because the redirection that Facebook does. Using HttpURLConnection you get the redirection url, and not the picture. – Rony Tesler Mar 29 '14 at 18:38
  • Sorry, I really want to know what has changed and working method stopped working. Redirection is not a recent change I think. – ilkinulas Mar 30 '14 at 19:53