Reputation: 45
I am using FirebaseUI to log in to my app. On returning from the login activity, the following onActivityResult
-override prints Here1-1
, which is as expected. However, immediately after, the activity finishes, which is not what I want. I feel really lost, does anyone have any idea what could be happening?
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode,resultCode,data);
switch (requestCode) {
case RC_SIGN_IN:
if (resultCode == RESULT_CANCELED) {
finish();
} else {
System.out.println("Here" + Integer.toString(requestCode) + Integer.toString(resultCode));
}
case RC_START_APP:
if (resultCode == RESULT_LOGOUT) {
signout();
} else {
finish();
}
}
}
Upvotes: 0
Views: 65
Reputation: 317322
Your cases need a break
to stop execution so they don't fall through to the next case. Your activity is actually just finishing due to executing the finish()
in the second RC_START_APP
case.
switch (requestCode) {
case RC_SIGN_IN:
if (resultCode == RESULT_CANCELED) {
finish();
} else {
System.out.println("Here" + Integer.toString(requestCode) + Integer.toString(resultCode));
}
break; // add this break
case RC_START_APP:
if (resultCode == RESULT_LOGOUT) {
signout();
} else {
finish();
}
break; // add this break
}
Upvotes: 2