我正在使用以下代码。我想要用户的出生日期,电子邮件和性别。请帮忙。如何检索这些数据?
这是我onViewCreated()
里面的碎片。
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Setup TextView.
mTextDetails = (TextView) view.findViewById(R.id.text_details);
// Set up Login Button.
LoginButton mButtonLogin = (LoginButton) view.findViewById(R.id.login_button);
// setFragment only if you are using it inside a Fragment.
mButtonLogin.setFragment(this);
mButtonLogin.setReadPermissions("user_friends");
mButtonLogin.setReadPermissions("public_profile");
mButtonLogin.setReadPermissions("email");
mButtonLogin.setReadPermissions("user_birthday");
// Register a callback method when Login Button is Clicked.
mButtonLogin.registerCallback(mCallbackManager, mFacebookCallback);
}
这是我的回调方法。
private FacebookCallback<LoginResult> mFacebookCallback = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d("Shreks Fragment", "onSuccess");
Profile profile = Profile.getCurrentProfile();
Log.d("Shreks Fragment onSuccess", "" +profile);
// Get User Name
mTextDetails.setText(profile.getName() + "");
}
@Override
public void onCancel() {
Log.d("Shreks Fragmnt", "onCancel");
}
@Override
public void onError(FacebookException e) {
Log.d("Shreks Fragment", "onError " + e);
}
};