Try this Code I hope Its Work..

   facebookimage(object.getString("id"));

This is Method:

 private void facebookimage(String id) {
        new getFacebookImage(id).execute();
    }

This is AsyncTask class to get Profile Image on Facebook ;

private class getFacebookImage extends AsyncTask {

        String userID;
        Bitmap camera;

        public getFacebookImage(String id) {
            userID=id;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected Object doInBackground(Object[] params) {


            URL imageURL = null;
            Bitmap bitmap=null;
            try {
                imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
                bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            Log.e("String Image",""+bitmap);
            camera=bitmap;
            return bitmap;
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);

            if(camera != null){
                Log.e("Image Load","UPload image");
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                camera.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                byte imageInByte[] = stream.toByteArray();
                String encodedImage = Base64.encodeToString(imageInByte, Base64.DEFAULT);
                DataBase.setUserImage(LoginActivity.this,encodedImage);

            }

        }
    }
Answer from Abhinav singh on Stack Overflow
Top answer
1 of 2
1

Try this Code I hope Its Work..

   facebookimage(object.getString("id"));

This is Method:

 private void facebookimage(String id) {
        new getFacebookImage(id).execute();
    }

This is AsyncTask class to get Profile Image on Facebook ;

private class getFacebookImage extends AsyncTask {

        String userID;
        Bitmap camera;

        public getFacebookImage(String id) {
            userID=id;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected Object doInBackground(Object[] params) {


            URL imageURL = null;
            Bitmap bitmap=null;
            try {
                imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
                bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            Log.e("String Image",""+bitmap);
            camera=bitmap;
            return bitmap;
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);

            if(camera != null){
                Log.e("Image Load","UPload image");
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                camera.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                byte imageInByte[] = stream.toByteArray();
                String encodedImage = Base64.encodeToString(imageInByte, Base64.DEFAULT);
                DataBase.setUserImage(LoginActivity.this,encodedImage);

            }

        }
    }
2 of 2
0

Initially I was getting only id and email in JSONObject object of onCompleted. Even though I set permissions like "public_profile" and "email" which is sufficient enough to get the id, name, email and profile picture from facebook. But somewhere I went wrong and didn't understand and added Profile and did getProfile() so I can get the name and profile picture. Then other problem arised was even after login perfectly, I was getting null profile sometimes(may be once in 5 times). For that had to put Profile Tracker and this was because Profile works Asynchronously(was too confusing for me as you have to put trackers and start & stop tracking).

Then I realized where I went wrong. In the bundle where we need to mention what all we want in the json object as reply, I had only mentioned "id". So now in the below code I added "name" and "email" as well. So in the JSONObject object response I get the name and email as well.

And for profile picture I saw How can I display the users profile pic using the facebook graph api? and implemented this using Uri builder Use URI builder in Android or create URL with variables . So with this I removed the use of Profile completely and still getting all the data I wanted.

This answer is the mixture of both the answers mentioned by Destro - Android Facebook Login- Profile is null & How to get email id From Android Facebook SDK 4.6.0?

FacebookCallback<LoginResult> facebookCallback = new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(final LoginResult loginResult) {


            GraphRequest request = GraphRequest.newMeRequest(
                    loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response) {

                            if (BuildConfig.DEBUG) {
                                FacebookSdk.setIsDebugEnabled(true);
                                FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);


                                String uid = object.optString("id");
                                String email = object.optString("email");
                                String name = object.optString("name");

                                Uri.Builder builder = new Uri.Builder();
                                builder.scheme("https")
                                        .authority("graph.facebook.com")
                                        .appendPath(uid)
                                        .appendPath("picture")
                                        .appendQueryParameter("width", "1000")
                                        .appendQueryParameter("height", "1000");

                                Uri pictureUri = builder.build();

                                try {
                                    sendLogin(uid, name, email, pictureUri.toString(), "fb");
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                                facebookLogout();

                            }
                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id, name, email");
                    request.setParameters(parameters);
            request.executeAsync();
        }

        @Override
        public void onCancel() {
        }

        @Override
        public void onError(FacebookException e) {
            Toast.makeText(getApplication(), "Something went wrong, please try again later", Toast.LENGTH_LONG).show();
        }
    };

    public void facebookLogout() {
        LoginManager.getInstance().logOut();
    }
🌐
Tom's Guide
forums.tomsguide.com › home › laptops › laptop tech support
Every time I try to log into my fb account it is saying null?? What do I do? | Tom's Guide Forum
April 20, 2016 - Every time I try to log into my fb account, it is saying null? What should I do?? Solution · Apr 20, 2016 · contact facebook to find why maybe you been block by them for something . Sort by date Sort by votes · C · Apr 20, 2016 · 2 · 0 · 1,510 · Apr 20, 2016 ·
Discussions

java - Why is user email null when signing into Facebook account, but not null when signing into Google account? - Stack Overflow
I'm using Firebase to allow the user to sign in with either their Facebook account or their Google account. I have allowed the creation for multiple accounts under the same email address. This is ... More on stackoverflow.com
🌐 stackoverflow.com
Why my Facebook saying null - Apple Community
Facebook, Instagram, and Whatsapp are all experiencing major outages today. Try again later. ... This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers. ... A forum where Apple customers help each other with their products. Get started with your Apple Account... More on discussions.apple.com
🌐 discussions.apple.com
October 4, 2021
I received a notification on messenger saying "null sent a message.". Next to that notification, there's a girl's profile picture. I checked my messenger including the spam folder and "message requests", but there's nothing in there. If I open the notification, will it display the girl's name?
Thank you for posting to r/facebook . Please read the following (this does not mean your post has been removed): SCAM WARNING: If you are having a problem with your account, beware of scammers who may comment or DM you claiming they know someone who can fix your account, or asking you for money or your login information. If you receive a message like this, block and report them. r/facebook is an unofficial community and the moderators are not associated with Facebook or Meta. Please read the rules in the sidebar (or the 'about' tab if you're on mobile). If your post violates any of them, delete it. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/facebook
14
9
April 6, 2023
What "null" Does Mean in My Profile on Br… - Apple Community
What "null" Does Mean in My Profile on Browse Communities on discussions.apple.com? ... A forum where Apple customers help each other with their products. Get started with your Apple Account. More on discussions.apple.com
🌐 discussions.apple.com
🌐
Facebook
facebook.com › public › Null
Null in people
We cannot provide a description for this page right now
🌐
Apple Community
discussions.apple.com › thread › 253219438
Why my Facebook saying null - Apple Community
October 4, 2021 - Facebook is having widespread service disruption today. It's not you, and it's not something you nor anyone here can affect.
🌐
HubSpot
community.hubspot.com › t5 › Ads › FB-Ad-Account-but-get-Pixel-ID-is-Null-error › m-p › 863789
Solved: HubSpot Community - FB Ad Account, but get Pixel ID is Null error - HubSpot Community
April 2, 2024 - Solved: Afternoon, I'm setting up a newer HS account with FB ads. I can connect the correct ad account, but when I go to add the pixel and use the
🌐
Facebook
facebook.com › help › 105487009541643
Recover your Facebook account if you can't log in | Facebook Help Centre
If you're having trouble with logging in to your account, review these tips and known login issues.
Find elsewhere
🌐
Facebook
facebook.com › NULLnull.NULL30
NULL
We cannot provide a description for this page right now
🌐
Apple Community
discussions.apple.com › thread › 255072336
What "null" Does Mean in My Profile on Br… - Apple Community
"null" (is like "nil" or "zero") Seems it just means you have not provided any personal info.
🌐
Facebook Developers
developers.facebook.com › community › threads › 2406214246310356
Why does the PHP SDKs AdAccountUser object return null data for everything but id on ->getAdAccounts()? - Developer Community Forum - Facebook for Developers
So what I'm wondering is why these fields return null in this call and how can I get this data? ... You need to stipulate the fields you want in the ->getAdAccounts() call. So: $adUser->getAdAccounts(['account_id', 'name', 'business', 'fb_entity', 'business_name']
🌐
GitHub
github.com › facebook › facebook-android-sdk › issues › 1132
Facebook Login - Obtain null Authentication token · Issue #1132 · facebook/facebook-android-sdk
November 7, 2022 - val fBLoginManager = com.facebook.login.LoginManager.getInstance() fBLoginManager.registerCallback(mFaceBookCallbackManager, object : FacebookCallback<LoginResult> { override fun onCancel() { Log.i(TAG, "facebook: onCancel") } override fun onError(error: FacebookException) { Log.i(TAG, "facebook: error$error") } override fun onSuccess(result: LoginResult) { Log.i(TAG, "facebook: onSuccess") //not empty val accessToken = result.accessToken //empty val authenticationToken = result.authenticationToken } }) fBLoginManager.logInWithReadPermissions(mFragment.fragment, mFaceBookCallbackManager, listOf("email", "public_profile"))
Author   DRPrincess
🌐
Ashryan
ashryan.io › facebook-dev-null
Facebook → /dev/null
March 18, 2025 - Maybe I should have put this one first, because if you're a developer who has built an app on Facebook, it seems like you need to delete or reassign those apps before they will let you delete your Facebook account.
🌐
Facebook Developers
developers.facebook.com › community › threads › 333069034377065
login sdk return accessToken null - Meta for Developers
Your Request Couldn't be Processed · There was a problem with this request. We're working on getting it fixed as soon as we can
🌐
Facebook
facebook.com › login › identify
Facebook
This browser isn't supported · tap to use a supported browser
🌐
Facebook
facebook.com › help › 132243923516844
Recover your Facebook account if you can't access ...
Learn how to use Facebook, fix a problem, and get answers to your questions.