Android Facebook SDK: Check if the user is logged in or not

后端 未结 10 1466
南旧
南旧 2020-12-04 12:43

I\'m have a feature on my Android app where the user authorizes the app and shares a link.

I also need to give an option for the user to logout of facebook and I nee

10条回答
  •  既然无缘
    2020-12-04 12:57

    This seems to be working quite well with the new sdk.

    private boolean isFacebookLoggedIn(){
        Session session = Session.getActiveSession();
    
        if (session != null) {
            //Session can be open, check for valid token
            if (!session.isClosed()) {
                if(!session.getAccessToken().equalsIgnoreCase("")){
                    return true;
                }
            }
        }
        return false;
    }
    

提交回复
热议问题