Session.openActiveSession only calls OPENING in Facebook Android SDK

前端 未结 1 1860
遥遥无期
遥遥无期 2021-01-13 18:36

I am trying to login with Facebook using the Facebook Android SDK, however, the status callback is fired only once with OPENING session state. After that, a Fac

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-13 19:07

    You need to call onActivityResult

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

    So when login done . It comes to same activity and calls status callback with session state is opened

    initialize UiLifecycleHelper

    private UiLifecycleHelper uiHelper;
    

    in oncreate need to call before setContentView

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

    and need to maintain session in

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

    0 讨论(0)
提交回复
热议问题