简体   繁体   中英

Facebook login fail with Android App

I am Using Facebook login for user registration in android app.It works for me but some times after clicking login button login window not open and screen hangup. As i guess this issue because of session time out,when app try to connect with Facebook but if Facebook not respond then this cause occur.So how can i solve this problem.

Thanks in advance.

Edited:- Code is -

private void initFacebook(Bundle savedInstanceState){
      uiHelper = new UiLifecycleHelper(this, callback);
      uiHelper.onCreate(savedInstanceState);
      mSessionTracker = new SessionTracker(this, callback);
      mSessionTracker.startTracking();
}

and call back method which will call when user click on login button are-

private Session.StatusCallback callback = new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            onSessionStateChange(session, state, exception);
           if(state!= null){
                if(state.isOpened()){
                    mSession = session;
                    if(mLoginButton != null)
                     mLoginButton.setText(getString(R.string.loginwithfacebook));
                    showLoadingView();
                }
            }

        }
 };


 private void onSessionStateChange(Session session, SessionState state, Exception exception) {
        if (pendingAction != PendingAction.NONE && (exception instanceof FacebookOperationCanceledException ||
                exception instanceof FacebookAuthorizationException)) {
                new AlertDialog.Builder(BaseActivity.this)
                    .setTitle(R.string.cancelled)
                    .setMessage(R.string.permission_not_granted)
                    .setPositiveButton(R.string.ok, null)
                    .show();
            pendingAction = PendingAction.NONE;
        } else if (state == SessionState.OPENED_TOKEN_UPDATED) {
           handlePendingAction();
        }
    }

but the call back method not called some times.

retry until it success, or tomorrow. facebook API was gone partially, it seems recovering... https://www.facebook.com/developers/chart.php?type=at_error_count

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM