Session.openActiveSession only triggers OPEN on Facebook Android SDK

I am trying to log in to Facebook using the Android Android SDK, however the status callback only starts once with the session state OPENING. After that, Facebook login activity appears without content (I know that this action, since it has a header that I set to title_facebook_loginin strings.xml) for a short time and disappears within a second. No other callback starts, no exceptions, no failures. He just waits forever in my initial activity. Here is my code:

Session.openActiveSession(parent, true, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if(state == SessionState.OPENED){
                String accessToken = session.getAccessToken();
            }
        }
    });

Why not call a callback for SessionState.OPENED(or CREATED, or even CLOSED), but only OPEN?

+4
1

onActivityResult

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

, .

UiLifecycleHelper

private UiLifecycleHelper uiHelper;

oncreate setContentView

uiHelper = new UiLifecycleHelper(this, statusCallback);
        uiHelper.onCreate(savedInstanceState);

    @Override
    protected void onResume() {
        super.onResume();
        uiHelper.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        uiHelper.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        uiHelper.onDestroy();
    }
+9

Source: https://habr.com/ru/post/1538255/


All Articles