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

限于喜欢 提交于 2019-12-01 12:52:16
Harvi Sirja

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
   
}

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.";
}});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!