I\'ve following problem with Facebook SDK 3.0 for Android. I wanna get my (and my friends) profile picture without using their ProfilePictureView widget, so if I use Graph Explo
As far as I know, it's not possible to get the image directly using the facebook graph API, because their API is designed to only accept JSON responses. It seems weird that they would allow a request that results in a non-JSON response, and especially strange that they would put that request in their official documentation *(https://developers.facebook.com/docs/graph-api/reference/user/picture/).
I am using the built in Android DefaultHttpClient library.
private Bitmap downloadImage(url) {
Bitmap image = null;
DefaultHttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(imageUrl);
try {
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
int imageLength = (int)(entity.getContentLength());
InputStream is = entity.getContent();
byte[] imageBlob = new byte[imageLength];
int bytesRead = 0;
// Pull the image's byte array
while (bytesRead < imageLength) {
int n = is.read(imageBlob, bytesRead, imageLength - bytesRead);
bytesRead= n;
}
image = BitmapFactory.decodeByteArray(imageBlob, 0, imageBlob.length);
} catch (Exception e) {
e.printStackTrace();
}
return image;
}