Why absolutely nothing happens after calling onActivityResult () in the CallbackManager using the Facebook login button?

I tried to figure out how to solve this but was unsuccessful.

The problem here is after clicking the login button, it usually loads the Facebook job and when it finishes, my activity gets the result of the activity and notifies the CallbackManager (everything as described in the docs).

Unfortunately, nothing happens from now on, no method from the registered FacebookCallback is executed, and not even a string is logged to report the error.

Here are the files involved:

public class LoginActivity extends Activity

    CallbackManager callbackManager;
    LoginButton loginFacebook;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(this);

        setContentView(R.layout.activity_login);


        ...


        callbackManager = CallbackManager.Factory.create();
        loginFacebook = (LoginButton) findViewById(R.id.login_button);
        loginFacebook.setReadPermissions("public_profile","email");
        loginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

            @Override
            public void onSuccess(LoginResult loginResult) {
                ...
                (This is never executed)
            }

            @Override
            public void onCancel() {
                ...
                (Not executed)
            }

            @Override
            public void onError(FacebookException e) {
                ...
                (Not executed either)
            }
        });

    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        callbackManager.onActivityResult(resultCode, resultCode, data);
        super.onActivityResult(requestCode, resultCode, data);
    }


    ...


}

      

And activity_login.xml includes a button like this

<com.facebook.login.widget.LoginButton
            android:id="@+id/login_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"/>

      

I also added Facebook activity and APP id in android manifest file.

<activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />

      

Same as android app app in facebook app.

Hope identifies a solution for this, thank you very much.

+3


source to share


2 answers


Ok, now I see. This is probably not true.

callbackManager.onActivityResult(resultCode, resultCode, data);

      



See resultCode

entered twice. What do you want to do:

callbackManager.onActivityResult(requestCode, resultCode, data);

      

+2


source


Try adding this to your manifest. xml between application



<activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" /><activity

      

+1


source







All Articles