android-simple-facebook
android-simple-facebook copied to clipboard
getProfile | Only getting user id and name
I am getting only userId and name in onComplete of onProfileListener rest entities like gender,bio, birthday, cover are null.
It seems to be a bug cause I also tried the sample code and got the exact same problem.
- Using Graph v2.5
- Asked for the right permissions
- Specified profile properties in my request
Code:
SimpleFacebook facebook;
Button loginBtn;
Permission[] permissions = new Permission[] {
Permission.USER_PHOTOS,
Permission.EMAIL,
Permission.PUBLISH_ACTION,
Permission.USER_BIRTHDAY
};
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
.setAppId("***********************")
.setNamespace("appnamespace")
.setPermissions(permissions)
.build();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
SimpleFacebook.setConfiguration(configuration);
loginBtn = (Button) findViewById(R.id.facebook_login);
loginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
facebook.login(onLoginListener);
}
});
}
OnLoginListener onLoginListener = new OnLoginListener() {
@Override
public void onLogin(String accessToken, List<Permission> acceptedPermissions, List<Permission> declinedPermissions) {
// change the state of the button or do whatever you want
Log.i(TAG, "Logged in :" + acceptedPermissions.toString());
Profile.Properties properties = new Profile.Properties.Builder()
.add(Profile.Properties.ID)
.add(Profile.Properties.NAME)
.add(Profile.Properties.FIRST_NAME)
.add(Profile.Properties.LAST_NAME)
.add(Profile.Properties.PICTURE)
.add(Profile.Properties.COVER)
.add(Profile.Properties.GENDER)
.add(Profile.Properties.BIRTHDAY)
.build();
facebook.getProfile(properties, onProfileListener);
}
@Override
public void onCancel() {
// user canceled the dialog
}
@Override
public void onFail(String reason) {
// failed to login
}
@Override
public void onException(Throwable throwable) {
// exception from facebook
}
};
OnProfileListener onProfileListener = new OnProfileListener() {
@Override
public void onComplete(Profile response) {
super.onComplete(response);
Log.d(TAG, response.toString()); //ONLY ID AND NAME
}
@Override
public void onFail(String reason) {
super.onFail(reason);
}
@Override
public void onException(Throwable throwable) {
super.onException(throwable);
}
};
@Override
protected void onResume() {
super.onResume();
facebook = SimpleFacebook.getInstance(this);
// Logs 'install' and 'app activate' App Events. :FACEBOOK
AppEventsLogger.activateApp(this);
}
@Override
protected void onPause() {
super.onPause();
// Logs 'app deactivate' App Event. :FACEBOOK
AppEventsLogger.deactivateApp(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
facebook.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
Yes I also start to have this issue. It is very weird. No more email I get just first name last name and id.
just use response.getEmail().toString()...and so on