Close app upon checkout

Asked

Viewed 278 times

0

Hello, I have an app, it comes down to: a Activity and a fragment. To activity calls the fragment through the onCreate:

Code of Activivity who calls the fragment:

 @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_mensagem);

            chamaSecondActivity();
        }

        public void chamaSecondActivity() {

            FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            fragmentTransaction.replace(R.id.containerMensagem, new SecondActivity());
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();

        }

I would like when you return from Fragment the app closes and does not return to Activity.

1 answer

0


You can remove this line from your code:

fragmentTransaction.addToBackStack(null);

It brings the button back, back from Fragment and not from Activity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.