Android developer and tech enthusiast. Love creating apps with good UI UX design. I also like to sketch and listen to Chillstep.

You may also like...

  • Firas

    Thanks its amazing post part1 and 2
    just about profile image :

    ProfilePhotoAsync profilePhotoAsync = new ProfilePhotoAsync(mFbProfile);

    what is mFbProfile and from where i can get it

    • If you go through my GitHub project, you can see that ‘mFbProfile’ is an object of com.facebook.Profile.
      I pass this to my AsyncTask’s constructor so I can use it to fetch my profile photo from Facebook.

  • Ecstasy

    Thanks for the great post.

    I have few issues with the code. Could you please help me with this error in my logcat
    sendUserActionEvent() mView == null

    I am unable to retrieve my facebook profile picture, name and email.

    • I’m afraid just that one line won’t help me in identifying the error. If you’ve gone though my post carefully, I have mentioned how to retrieve all 3 values.

      • Ecstasy

        I had been closely going through the whole code many times but I think I have a problem with getUserDetailsFromFB() function as I am not able to retrieve any user information as a username I am getting a long string as shown in the attachment. Please help me resolve this matter as I am new to both Android and Parse.

        • Have you setup the SDK properly? I’ve gone over this in great detail in Part 1. Make sure that is properly configured first.

          • Ecstasy

            I have rechecked the whole procedure but still getting the same thing. Could you please tell me if there is something to do with facebook permissions?

            I want to show you my logcat as well. Please help me resolve this matter.

          • Do post your error log, so I could take a look?

          • Ecstasy

            I am unable to post my logcat here as it requires a permission to be pasted here.

          • Please use StackOverflow and post the error along with relevant code snippet there. That way I can take a look and help you out.

  • logInWithReadPermissionsInBackground() will throw a ParseException via done(). Try to catch that exception and see what error it is. That will help find your issue.

  • From the looks of it, your user is able to log in through Facebook but you’re having trouble retrieving the saved details from Parse.
    Check if you have this line.

    parseUser = ParseUser.getCurrentUser();
    I suspect your current user is going null somewhere, so do a check before calling it in.
    Also, after fetching your username from Facebook and before saving it, try dumping the username to the logs to see what it is. So you’ll know if you’re actually fetching the right username or just garbage.

  • Mostafa Anter

    thanx for great tutorial

  • Mostafa Anter

    thanx for best tutorial ,

    i have one issues why you you use saveNewUser()??? parse SDK receives the user’s Facebook access data and saves it to a ParseUser. If no ParseUser exists with the same Facebook ID, then a new ParseUser is created.

    • Unfortunately, I’m not aware of the recent developments with Parse. But at the time of writing, I had to manually save those details as a new ParseUser.

  • Assalamoalaikum.
    You are just awesome, my bro!

    Thanks for this super helpful tutorial!

  • Rama Srinivas

    Thank you for your post

    But for me the following part of the code is not executing

    public void onCompleted(GraphResponse response) {
    /* handle the result */
    try {
    email = response.getJSONObject().getString(“email”);
    Log.d(“Email”, email);
    name = response.getJSONObject().getString(“name”);
    Log.d(“Name”, name);

    } catch (JSONException e) {

    • Hi Rama,
      Is that part of the code not being executed AT ALL, or is there some kind of error? Could you cross check your code against mine once?

      • Rama Srinivas

        Hi Suleiman,

        I had tried a lot the code is getting executed. But the problem is that If I am giving the “email” permission but I not able to retrieve the email Id. In my Json response I am only obtaining “id” and “name” parameters. So from the try block in the following line the code is going to catch block.

        email = response.getJSONObject().getString(“email”);

        Due to no “email” parameter.

        Now I need to fetch the email Id of the user. so please help me out.

        • Before trying to fetch ’email’ I’d print the response to the logs, to see what I’m getting first.

  • This tutorial isn’t working for me, bro!!! 🙁

    I’m unable to fetch anything from facebook.

    • That doesn’t tell me anything with which I can help you with.

      • the problem I am encountering is that this code is not fetching user’s proper name for ex- my name is ‘Hammad Nasir’ but the name it is fetching and displaying is ‘CZ6K9iirFRUlfVW8PEWzpDgvV’. Another problem is that it is not fetching the email & profile picture.
        Please help with this.

  • bossdog22

    Great tutorial, really cleared things up for me. Problem I’m having now is I can’t retrieve user details from Facebook? At the very end of the getUserDetailsFromFB() method I put: System.out.println(“The email retrieved is ” + email + ” username is ” + name); in order to see what values are being returned. In the logcat both items are always null? Any ideas as to what I’m doing wrong?

    • Hey there,
      Happy to know the tutorial was useful. Which version of the SDK are you using? Please cross check against the part 1 setup against mine for me? If you still face problems, let me know.

      • bossdog22

        I have Parse-1.9.1.jar & ParseFacebookUtilsV4-1.9.1.jar. In the build.gradle I have compile ‘ Should I compile a different version with those jars?

      • bossdog22

        Following what you did in part 1 but the problem remains. Compile ‘’ is added to gradle with FacebookUtilsV4-1.9.1.jar in the libs folder…

        • To my knowledge, the current Facebook SDK is 4.7.0 and Parse would be updated as well. Please update relevant libraries first.

          • Posts have been updated to use the latest SDKs!

  • Michael Lorenz Jimenez- Labrad

    Thank you for the very useful tutorial. I have able to connect with parse and link it with fb. also I was able to fetch my profile pic and applied it in my app. But my problem is the part of getUserDetailsFromFB. I dont understand why I cant fetch my fb username and email.. I also added try catch in order to find the exception but it does not display any in logcat.. it only says in my app that “Welcome 9yreuyuynfjeuy….”.I believed that it didnt fetch any data in my fb. btw i am using fb sdk 4.7 and parse jar provided in the parse quick start. Any idea how to fix it?

    • this is the same problem I’m tackling with.
      hve you figured out the solution?

    • Hi Michael,
      You need to request for the email ID explicitly (Changes made in the new SDK). Check out Dominique’s reply.

  • Dominique Canlas

    Has anyone found a solution with regards to FB not returning all user details when requested? I verified my access token and that I have proper permissions. I am getting the name and fbId returned but not the email. Is it possible that it has something to do with app still in development mode or not released in the marketplace yet? Thanks for any response.

    • Dominique Canlas

      Update: Finally figured this out after hours of searching around in the FB docs. By default, the “/me” route only returns name and id. In order to get the email (or other fields), you have to explicitly request for it. You can just do:

      Bundle parameters = new Bundle();
      parameters.putString("fields", "email,name");

      Just include “parameters” in the GraphRequest arguments.
      Hope this helps anyone who is encountering the same problem!

    • Hey Dominique,
      Thats awesome! Good to see you got it solved. In the earlier versions, using the “/me” path fetched the email as well, but the new SDK requires you to pass that as a parameter.
      Thanks for helping out. Hopefully I’ll be updating the post today.


      • Part 1 and 2 have now been updated to the new SDKs.

  • Hi there,
    Both part 1 & 2 of this post has been updated with the latest SDKs. Please revisit them and do the changes to get it working.

  • Check the updated posts

  • Hi there,
    I’ve checked to make sure it works with the latest SDKs. You might want to go through part 1 and see if you’re using the correct versions.

    PS: All imports are now through Gradle. (No JARs)

  • Andrew Kurth

    hi, i dont understand where musername, memail, and mpermissions come from. I followed every step, but am getting errors. Please reply asap. What i am confused about is the fact that you do not define them anywhere before in your code.

    • mUsername and mEmailID are simply TextViews. mPermissions is a paramater needed by ParseFacebookUtils. It is simply the permissions from Facebook which you require.

      You can refer the GitHub link for code, at the post’s end.

  • Cristian Dregan

    Is there a way to get larger than 50×50 image?