Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 261
VicVu Avatar asked Nov 07 '12 16:11

VicVu


1 Answers

Whoops! Forgot my activity result!

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

That did the trick.

like image 131
VicVu Avatar answered Nov 06 '22 21:11

VicVu