0

I have changed the Facebook sdk for older version to new version 4.x and successfully integrated the login through login manager

     LoginManager.getInstance().registerCallback(callbackManager,
                        new FacebookCallback<LoginResult>() {
                            @Override
                            public void onSuccess(LoginResult loginResult) {
                                // App code
                                Profile profile = Profile.getCurrentProfile();
                                fb_first_name = profile.getFirstName();
                                fb_last_name = profile.getLastName();
                                facebookId = profile.getId();
                                Log.print("System out", "fb_first_name-------------> "+fb_first_name+"\fb_last_name-------------> "+fb_last_name+"fbID-------------> "+facebookId);

                            }

                            @Override
                            public void onCancel() {
                                 // App code
                                Toast.makeText(getApplicationContext(), "onCancel ", Toast.LENGTH_LONG).show();
                            }

                            @Override
                            public void onError(FacebookException exception) {
                                 // App code   
                                Toast.makeText(getApplicationContext(), "onError" +exception.toString() , Toast.LENGTH_LONG).show();
                            }
                });

But when I logout from one user and login from another the profile displays is of older user. How can I get the profile of new user? I have also tried below code to get the updated profile.

profileTracker = new ProfileTracker() {
                @Override
                protected void onCurrentProfileChanged(
                        Profile oldProfile,
                        Profile currentProfile) {
                    // App code
                    fb_first_name = currentProfile.getFirstName();
                    fb_last_name = currentProfile.getLastName();
                    facebookId = currentProfile.getId();
                    Log.print("System out", "fb_first_name-------------> "+fb_first_name+"\fb_last_name-------------> "+fb_last_name+"fbID-------------> "+facebookId);


                    Toast.makeText(getApplicationContext(), "onSuccess"+currentProfile.getName(), Toast.LENGTH_LONG).show();
                    handler.sendEmptyMessage(0);
                }
            };
  • Does the `onCurrentProfileChanged` method get called for the second user? Sometimes the `Profile` takes a couple milliseconds/seconds to update – Marco Batista Aug 17 '15 at 11:14
  • yes, I have displayed the toast. – Avani Nagar Aug 17 '15 at 11:20
  • did you allowed login for public in facebook console ? – Rahul Aug 17 '15 at 11:30
  • Where can i get this option. Can you suggest me so that I can re-check. Btw I was able to login and get the user profile info when I was using the older fb sdk. Let me know if there is addition check updated by facebook – Avani Nagar Aug 17 '15 at 12:15
  • 1
    on `onCurrentProfileChanged` the currentProfile is still the old one? And the oldProfile, what is the info on that one? – Marco Batista Aug 18 '15 at 11:51

0 Answers0