Follow the below steps
- From the
MainActivity
you need to call thefinish()
method after you pass intent toListAllActivity
- In the
ListAllActivity
call the finish() method on your button click or just press the back button as back button by default callfinish()
method. - In this way you will exit from your app.
On the next button click of MainActivity
write below code
Intent intent=new Intent(MainActivity.this,ListAllActivity.class);
startActivity(intent);
finish();
and on the ListAllActivity
back button write below code
finish();