How to GoTwo Activities back in Android?

Suppose  I have Activities which are in the sequence Activity01 => Activity02 => Activity03

you can go from Activity1 to Activity2 by using button clicks and likewise from Activity 2 to Activity 3.


then after getting a result from Activity 3,if we want to go directly to Activity 1,we use


android:noHistory="true" on Activity02 in the manifest and just call finish() on Activity03.

if we do this,after finishing activity3,itd irectly goes to Activity1.

Alternate method


intent i = new  intent(Activity2.this,Activity3.class);
startActivity(i);
i.setflags(i.FLAGS_NO_HISTORY);
finish();


*This is used in situations like login redirects etc.