LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(final LoginResult loginResult) {
if(Profile.getCurrentProfile() == null) {
mProfileTracker[0] = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile profile, Profile profile2) {
Log.v("facebook - profile", profile2.getFirstName());
storeLogin(profile2.getName(), profile2.getProfilePictureUri(450, 450).toString(), loginResult.getAccessToken().getUserId());
openMainActivity(profile2.getName(), profile2.getProfilePictureUri(450, 450).toString(), loginResult.getAccessToken().getUserId());
loadingFace.dismiss();
mProfileTracker[0].stopTracking();
}
};
mProfileTracker[0].startTracking();
}
else {
Profile profile = Profile.getCurrentProfile();
storeLogin(profile.getName(), profile.getProfilePictureUri(450, 450).toString(), loginResult.getAccessToken().getUserId());
openMainActivity(profile.getName(), profile.getProfilePictureUri(450, 450).toString(), loginResult.getAccessToken().getUserId());
loadingFace.dismiss();
}
}
@Override
public void onCancel() {
....