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

后端 未结 2 1283
北恋
北恋 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:23

    Facebook remove session in new SDK. check my answer for same question

    there full integration code is given by me.

    you can check whether user is logged in or not by this code.

    profile = Profile.getCurrentProfile().getCurrentProfile();
    if (profile != null) {
    	// user has logged in
    
    } else {
    	// user has not logged in
       
    }

    0 讨论(0)
  • 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<LoginResult>() {
    @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.";
    }});
    
    0 讨论(0)
提交回复
热议问题