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);
}
};