0
I am implementing the facebook sdk to log in to my application. I have two activities that I call Login and Home. When I click the login button, the login is performed perfectly and the 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 code instance twice to Activity Home.
Try to override the
onBackPressed
at Activity Home. Check that you are logged in and only finish Activity Home without calling super method (there should be a better solution).– Androiderson
I did it myself, but like you said, I don’t think it’s the best solution.
– user3174
You have to finalize the acitivity of the new Activity that you are calling, no?
– Felipe Avelar
Yes. When you press the back button of the device this is exactly what happens.
– user3174
I mean, pass the
Bundle
ofintent
the reference to Activity login and, when starting the other Activity, ends the login Activity.– Felipe Avelar
I edited the question
– user3174
This issue changes a lot. If you have two instances of Homeactivity you will have to show more code because the problem is definitely not there.
– Androiderson