Answer the question
In order to leave comments, you need to log in
How to exit to the main screen of the device from an application that first destroys the fragment (leaving a void), after pressing the back button?
The point is this. There is MainActivity. It has two fragments: a MapFragment to display a Google map, and my own fragment, let's say the CurrentFragment.
The transaction is done like this (I pass null to the backstack)
private void beginTransactionWithReplacement(Fragment currentFragment, String backStackString){
getSupportFragmentManager().beginTransaction()
.replace(R.id.store_container, currentFragment)
.addToBackStack(backStackString)
.commit();
}
Answer the question
In order to leave comments, you need to log in
Don't make .addToBackStack(backStackString)
the fact that you passed null there means that the transaction name in the backstack is null and the transaction is still in the backstack. Just don't add it there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question