I have successfully installed the android sdk v4.0 in my studio. I get to login correctly using LoginButton.
So far everything ok.
I want to have a string for each user data collecting interests me, for example:
String name = USER_NAME String = USER_MAIL mail.
With the 3.0 sdk had it properly.
With the new SDK can not I do this, I followed the instructions in this thread:
Android Facebook 4.0 SDK How to get Email, Date of Birth and gender of User
I read in the documentation and in various threads about "Using the Graph API" but I can not get the data I'm looking for and assign them to each string.
this is my code (just as it is now):
LoginButton loginButton;
private CallbackManager mCallbackManager;
//...
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("public_profile, email, user_birthday, user_friends"));
mCallbackManager = CallbackManager.Factory.create();
//...
loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Toast.makeText(Ready.this, "Connected!", Toast.LENGTH_SHORT).show();
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
Log.v("LoginActivity", response.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
// App code
Log.v("LoginActivity", "cancel");
}
@Override
public void onError(FacebookException exception) {
// App code
Log.v("LoginActivity", exception.getCause().toString());
}
});
As I said before, I connect with facebook perfectly, but do not know how to assign, for example, email to a string and name to another string.
Thank you very much in advance.