Android - Facebook Integration: Impossible to Import com.facebook.Session

后端 未结 2 1284
北恋
北恋 2021-01-16 07:45

i\'m new on android - facebook integration.
I\'m trying to integrate my app with facebook, so i follow all the steps on the facebook tutorial, and things work fine (at le

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-16 08:44

    After looking around, i realize that the Session class on the new facebook SDK is not used. Instead that i found something like this, it solved my question:

    loginButton = (LoginButton)findViewById(R.id.login_button);
    loginButton.registerCallback(callbackManager, new FacebookCallback() {
    @Override
    public void onSuccess(LoginResult loginResult) {
        Log.e("Content", "User ID: " + loginResult.getAccessToken().getUserId() + "\n" + "Auth Token: " + loginResult.getAccessToken().getToken());
    }
    
    @Override
    public void onCancel() {
        //"If login attempt canceled.";
    }
    
    @Override
    public void onError(FacebookException e) {
        //"If login attempt Failed.";
    }});
    

提交回复
热议问题