Skip to content Skip to sidebar Skip to footer

Facebook Login Callback Fires Multiple Times

My app is having Share button to share story on users timeline. What I'm doing is, user taps on Share button, if user session is not present app forces to Login user with Facebook.

Solution 1:

remove all the publishStory() calling. in your callback do this:

public void call(Session session, SessionState state,
        Exception exception) {
    if(session != null && session.isOpened() && isShared){
       publishStory();
    }
}

in your UpdateDetails class declare isShared as boolean isShared = false; and when user tap on share button make it true, like:

shareBtn.setOnClickListener(newOnClickListener() {
    @OverridepublicvoidonClick(View arg0) {
        isShared = true;
        doPostStory();                              
    }
});

in your publishStorys onComplete make isShared false. like:

publicvoidonCompleted(Response response) {
    isShared = false;
    ...................
    ...................
}

hope this will help.

Solution 2:

Create Facebook Session Object Then Just Apply This in onCreate Method.

 Session.openActiveSession(this, true, newSession.StatusCallback() {

        // callback when session changes state@Overridepublicvoidcall(Session session, SessionState state,
                Exception exception) {
            if (session.isOpened()) {

                // make request to the /me API
                Request.newMeRequest(session,
                        newRequest.GraphUserCallback() {

                            // callback after Graph API response with user// object@OverridepublicvoidonCompleted(GraphUser user,
                                    Response response) {
                                FacebookLoginActivity.this.progressDialog = ProgressDialog
                                        .show(YourActivity.this,
                                                "",
                                                "",
                                                true);
                                if (user != null) {

                                   IntentpassIntent=newIntent(YourActivity.this,Second.class)
                                   startActivity(passIntent)
                                }
                            }
                        }).executeAsync();

            }
        }
    });

Post a Comment for "Facebook Login Callback Fires Multiple Times"