Android Facebook SDK v3.0 SSO LoginButton returning a null GraphUser

依然范特西╮ 提交于 2019-12-12 10:54:49

问题


So I have a simple login button that does this in my oncreate:

 mLoginButton = (LoginButton)findViewById(R.id.connect_facebook_button);
    mLoginButton.setApplicationId(.getResources().getString(R.string.app_id));
    mLoginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
        public void onUserInfoFetched(GraphUser user) {
            setUser(user); // Just sets mUser to be this user
            try {
            Toast.makeText(this, mUser.getFirstName(), Toast.LENGTH_SHORT).show();
            } catch (Exception FacebookException) {
                FacebookException.printStackTrace();
            }


        }
    });

All of that is called successfully, including the onUserInfoFetched.

The problem is, in every instance, my Graphuser user is null.

My appID is correct, my android hash is the debug one that they give me (tested on sample apps worked fine), the login screen does actually pop up... Not really sure where to go from here.

Also, if I hit the button twice, I get an error:

an attempt was made to open a session that has a pending request

回答1:


Whoops! Forgot my activity result!

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data); 
}

That did the trick.



来源:https://stackoverflow.com/questions/13274165/android-facebook-sdk-v3-0-sso-loginbutton-returning-a-null-graphuser

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