Why is the Activity instantiated twice?

0

I'm implementing facebook's sdk to sign in to my app. I have two Activities that I call Login and Home. When I click the login button, login is done perfectly and Activity Home is instantiated as soon as the onSessionStateChange method is called:

private void onSessionStateChange(Session session, SessionState state,
        Exception exception) {
    if (state.isOpened()) {
        Intent intent = new Intent(getActivity().getBaseContext(), HomeActivity.class);
        startActivity(intent);
        getActivity().finish();
    } else if (state.isClosed()) {
        Log.i(TAG, "Logged out...");
    }

}

The problem is that the instance code is twice the activity activity.

    
asked by anonymous 02.02.2014 / 23:46

1 answer

0

There is a great chance that the callback onSessionStateChange is being called more than once with the same status.

There are scenarios where this can happen, such as the point where you are making your initial call.

If it is in onResume try to change it to onCreate .

    
03.02.2014 / 17:01