Hi, Im attaching a snippet from my code:
protected void onCreate(Bundle savedInstanceState) { FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create();
fbloginButton= (LoginButton) findViewById(R.id.login_button);
fbloginButton.setReadPermissions("public_profile", "email","user_friends");
temp = (TextView) findViewById(R.id.temp);
}
private void FBLogin() {
System.out.print("Initializing facebook login");
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
temp.setText("Welcome " + loginResult.getAccessToken().toString());
//System.out.print(loginResult.getAccessToken());
final AccessToken accessToken = loginResult.getAccessToken();
GraphRequest graphRequest = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
try{
usermail = object.getString("email");
uname = object.getString("name");
}
catch (Exception e){
e.printStackTrace();
}
SocialService socialService = App42API.buildSocialService();
socialService.linkUserFacebookAccount(usermail, accessToken.toString(), new App42CallBack() {
@Override
public void onSuccess(Object o) {
}
@Override
public void onException(Exception e) {
}
});
}
});
}
Okay so what is happeneing is that, the login is working i guess! Becasue when i click on login, the Facebook UI opens up and asks for permission to login. I can say this because, the login button changes to a logout button automatically and when i click on it, it gives a proper popup that i was logged in as <name>.
The issue now is that the method onSucess() in the FacebookCallback is not beijng called since the temp text is not being changed and as a resut the rest of the code including the registerOnApp42 for the facebook is not working,
Itll be great if you can help me fix this.