Apparently I did find a solution to my problem. I just start the MainMenuActivity
from the LoginActivity
like this:
private void continueToMainMenu() {
Intent intent = new Intent(this, MainMenuActivity.class);
startActivityForResult(intent, 0);
}
Then, when the user presses the backbutton in the main menu, this overwritten function gets called:
public void onBackPressed() {
setResult(LoginActivity.ACTION_QUIT);
finish();
}
This will at first set a resultcode for the LoginScreen
and then finish the MainMenuActivity
. Then the LoginActivity
does terminate receiving this particular resultcode, which I implemented like this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == LoginActivity.ACTION_QUIT)
{
finish();
}
}
Doing it this way will ensure not to touch too deep into the activity lifecycles, all the callbacks to clean up will still be called and it should not open any security leaks.
Hope this helps if anyone else will bump into the same issue.