I\'ve got 4 activities say Act1, Act2, Act3 and Act4.
A button in Act1 opens Act2, a button in Act2 opens Act3, a button in A
finish previous activity when you are go to the next activity means write finish(); after startactivity(intent); and write below code for start first activity from fourth activity's button click event.
Intent in1=new Intent(Act4.this, Act1.class);
startActivity(in1);
finish();
And Write Below Code on Your Exit Button's Click event in all activities.
finish();