EDIT: Anwser at the end of this post.
I am trying to get a Facebook user's profile picture thanks to the inbuilt Facebook SDK's function Request()
.
I am using a /me/picture
call to get the profile picture and convert it into a Bitmap
.
The call is working fine but I don't know how to interpret and parse the result returned from Facebook
Here is the JSON
that I get:
{ "FACEBOOK_NON_JSON_RESULT" : "����\u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000��\u0000\u0004*\u0000��\u0000C\u0000\u0006\u0004\u0005\u0006\u0005\u0004\u0006\u0006\u0005\u0006\u0007\u0007\u0006\b" }
I think this should be representing the profile picture but I don't know what to do with this now.
If somebody could tell me either how to decode it, convert it to a Bitmap or what kind of data it is, I would be grateful.
NOTES: I don't want to use any other function than Request(), like DecodeStream() or an AsyncTask
Here is the answer:
When making a new Request()
you need to add the "redirect" parameter to false
:
Bundle params = new Bundle();
params.putBoolean("redirect", false);
This will return the correct picture URL:
{
"data":{
"is_silhouette":false,
"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xpa1\/v\/t1.0-1\/p100x100\/10312434_10152395442477210_2933994167675146084_n.jpg?oh=f3c8cb920c97fcfa4dc5e17462445cbf&oe=54404A3A&__gda__=1412730795_5f288e34e5f6e63cb1c3791dcb142880"
}
}
Apple and Google both have fantastic app stores. But Android is far superior at organizing apps, letting you put important stuff on the home screens and hide less useful apps in the app drawer. Also, Android's widgets are much more useful than Apple's.
Android Inc., was bought by the American search engine company Google Inc., in 2005. At Google, the Android team decided to base their project on Linux, an open source operating system for personal computers.
Android OS is a Linux-based mobile operating system that primarily runs on smartphones and tablets. The Android platform includes an operating system based upon the Linux kernel, a GUI, a web browser and end-user applications that can be downloaded.
Though Samsung has dabbled with other mobile operating systems, all Samsung Galaxy smartphones use the Android operating system. Simply put: Android is the operating system, Samsung is the manufacturer.
Try this :
ImageView user_picture;
userpicture=(ImageView)findViewById(R.id.userpicture);
URL img_value = null;
img_value = new URL("http://graph.facebook.com/"+id+"/picture?type=large");
Bitmap mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
userpicture.setImageBitmap(mIcon1);
Where ID is one your profile ID.
For Further details check this :
https://developers.facebook.com/docs/graph-api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With