Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2018 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dc77c8388343348314f8bbad3909b028 to your computer and use it in GitHub Desktop.
Save anonymous/dc77c8388343348314f8bbad3909b028 to your computer and use it in GitHub Desktop.
Facebook Android Get Profile Picture
********************
Facebook Android Get Profile Picture ->->->->
********************
http://shurll.com/bzvrq
(Copy & Paste link)
********************
Try to open link "graph.facebook.com/USERUID/picture" in browser - the link "httpS://fbcdn-profile-a.akamaihd.net/." will be opened. Running a Business. Email Sign Up or sign in with Google Facebook Android - get facebook profile picture Ask Question up vote 40 down vote favorite 19 I don't know why, but I am always getting null when I try to get the profile picture of the user. Android StudentHi Friends, How to implementation Google Plus in android? please help me& Jose Pablo MBYou rock waaaaaaaaay too much dude! Thanks Pratik Gondil10-16 11:32:01.134 1309-1339/? E/InputDispatcher channel d28cc11 com.example.dipali.learn2crackfb/com.example.dipali.learn2crackfb.MainActivity (server) Channel is unrecoverably broken and will be disposed! This error occur and emulator is directly terminated.How can i resolve this error /Hey bro, first of all thank you for sharing this helpful tutorial and i want to know to more . Not the answer you're looking for? Browse other questions tagged android facebook profile or ask your own question. How to read all these information.??? Aarti RamolaHi, Thanks for the tutorial.It was really helpful. Create ProjectCreate an New project in Android Studio by File->New Project. The request is executed by calling the executeAsync() method on the GraphRequest object. I added an answer that is slightly different; I use URL.openConnection().getInputStream() instead of URL.getContent(); –Jeffrey Klardie Nov 8 '13 at 9:25 add a comment 25 Answers 25 active oldest votes up vote 59 down vote This should work: public static Bitmap getFacebookProfilePicture(String userID){ URL imageURL = new URL(" + userID + "/picture?type=large"); Bitmap bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream()); return bitmap; } Bitmap bitmap = getFacebookProfilePicture(userId); Edit: As suggested by dvpublic in the comments, the problem of image not being downloaded is fixed using by "https" in favour of "http". Join Stack Overflow to learn, share knowledge, and build your career. more stack exchange communities company blog Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Log In Sign Up . shareimprove this answer answered Sep 20 '14 at 14:25 user3581447 754 3 Why should we use this code? How does it work? Code-only answers are liable to be deleted because they don't help others to understand how to solve a problem, and instead just solve it for them, –Wai Ha Lee Sep 11 '15 at 9:24 add a comment up vote 0 down vote You are getting null because the call to URL.openConnection() (or any other mechanism to fetch the image) is asynchronous. How the user can invite to all their friendlist through my application Parth VoraHello, I am using android studio and i tried to implement your code and it works, but i am using fragments&.and i have some problem that when i click on the share button, a share dialog appears but it is not like your screenshots sharedialog, instead it shows a message writing box only. (LogOut/Change) You are commenting using your Google+ account. i have updated answer –Rajesh Feb 26 '16 at 5:40 add a comment up vote 8 down vote Best way to Get Profile Picture URL int dimensionPixelSize = getResources().getDimensionPixelSize(com.facebook.R.dimen.comfacebookprofilepictureviewpresetsizelarge); Uri profilePictureUri= Profile.getCurrentProfile().getProfilePictureUri(dimensionPixelSize , dimensionPixelSize); or Uri profilePictureUri = ImageRequest.getProfilePictureUri(Profile.getCurrentProfile().getId(), dimensionPixelSize , dimensionPixelSize ); Use Glide to show Image Glide.with(this).load(profilePictureUri) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(profilePictureView); No more hard-coded string shareimprove this answer edited Jul 18 '17 at 4:46 answered May 24 '16 at 15:14 OM PRAKASH SEERVI 15124 No more hard-coded strings! Amazing! –Antonio Dec 17 '16 at 21:47 1 there is also a built in function to get the profile image in the Profile object: Profile.getCurrentProfile().getProfilePictureUri –Noam a Jul 17 '17 at 10:05 add a comment up vote 4 down vote check the user Id use this url imgurl=" shareimprove this answer answered Nov 8 '13 at 10:38 Amit kumar 1,22111424 add a comment up vote 4 down vote I always received a response stating a FACEBOOKNONJSONRESULT. But I am unable to make it work under fragment If I use it in fragment, when I click on Log in with facebook button -> for a second it says loading, then switch back to login fragment. Atul TiwariHi. Make sure you have used the same registered Package and Class name in your application.Add Facebook SDK in Android Studio ProjectFirst we need to add the maven central repository from which the Facebook SDKwill be downloaded and integrated. Courtesy of Facebook . Were you able to solve it ? Krishna DevAm not solve that, if you know please tell me Krishna Devi am solve that error, show the hash key on error page(uEH8T1AQsFWTUdkh2Xyeqzyk+E=), put your Facebook key hash generated web page rpit PatelYour key hash is not right see developer.facebook.com For check key hash use this code in onCreate() methodpublic void printHashKey(){ // Add code to print out the key hash try { PackageInfo info = getPackageManager().getPackageInfo( net.simplifiedcoding.androidlogin, PackageManager.GETSIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance(SHA); md.update(signature.toByteArray()); Log.d(KeyHash:, Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } }and check your logcat for key hash and copy this key hash and put into your developer.facebook.com=> app=>setting Android StudentHey Bro, How to set social login (Facebook & Google+) in a Android application ?, at same time am using set single logout button it work clear all include Facebook & Google+, Please help any one&&&. Ashish Tiwarihow can i share a particulate things from my app like Image View with text Mohammed Raheezsimple and awesome tutorial.was just searching for the post sharing part and just got the thing i needed .nicely done keep going !!! Himanshu JoshiHey I followed the tutorial and it was great help. / Uncategorized Get Facebook Profile Picture in AndroidApp December 31, 2017January 8, 2018 PanchalVipulLeave a comment Hello there &! Guys, many of you Android Coder, Want to get / fetch profile picture from the Facebook profile and want to set it in Activity. Facebook starts to get pretty. Tread at your own risk! –n8yn8 Feb 26 '16 at 5:43 add a comment up vote 1 down vote When you make request like this: it makes a redirect to other url. You wil need to configure project under facebook developer account and will then have to paste the link in your code. Hence the correct request must be: Bundle params = new Bundle(); params.putBoolean("redirect", false); new GraphRequest( AccessToken.getCurrentAccessToken(), "me/picture", params, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { try { String picUrlString = (String) response.getJSONObject().getJSONObject("data").get("url"); //Load picture url in imageView Glide.with(this).load(picUrlString).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(profilePictureView); } catch (JSONException IOException e) { e.printStackTrace(); } } } ).executeAsync(); shareimprove this answer edited Jul 5 '16 at 8:03 answered May 28 '16 at 7:43 Ravi Vaghela 1,8301738 add a comment up vote 2 down vote imgUrl = " + userid + "/picture?type=large"; then Picasso.with(getApplicationContext()).load(imgUrl).into(imageView); shareimprove this answer answered Dec 27 '15 at 12:13 Misho Zhghenti 125112 It worked for me !!! –Nguyn Trung Hiu Jun 6 '16 at 8:03 add a comment up vote 2 down vote I think problem is in the imageURL = "**http**://graph.facebook.com/"+userID+"/picture?type=large"; Use https insted of http shareimprove this answer edited Jan 4 '16 at 4:51 ketan 14.1k123158 answered Jan 4 '16 at 4:31 Arpit Patel 4,21932941 worked. ToolsGraph API ExplorerOpen Graph DebuggerObject BrowserJavaScript Test ConsoleAPI Upgrade ToolFacebook Analytics. The ProfilePictureView is used to display the users profile picture. First of all thanks for that. The wall. shareimprove this answer answered Oct 23 '14 at 14:18 ian 14811 add a comment up vote 0 down vote I have done this way: Get Bitmap from Image Url of Facebook: String imageUrl = " Bitmap bitmap = getFacebookProfilePicture(imageUrl); Function for Bitmap: private Bitmap getFacebookProfilePicture(String url){ Bitmap bitmap = null; HttpGet httpRequest = new HttpGet(URI.create(url)); HttpClient httpclient = new DefaultHttpClient(); HttpResponse mResponse; try { mResponse = (HttpResponse) httpclient.execute(httpRequest); HttpEntity entity = mResponse.getEntity(); BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); bitmap = BitmapFactory.decodeStream(bufHttpEntity.getContent()); httpRequest.abort(); } catch(Exception e){ e.printStackTrace(); } return bitmap; } It's Done 5a02188284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment