Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to come back to first activity from third activity?

Tags:

android

I have three activities A,B & C.Now the Task i have this form A,B and C,in default android "standard"mode The activities navigation takes place like this A->B->C->B->A.Now What I want here is when I went to Activity C from B,when i backPressed In activity I went to previous Activity i.e.,B But i want to come back to A from C.How to achieve this could anyone tell about this??

,I want to do through intent flags or if possible want to apply launchmodes for the activities,But i am confused which launch mode should i use to achieve this ?-could any one please help me in this

Thanks In Advance

like image 290
Sindhu Perumalla Avatar asked Jul 24 '12 08:07

Sindhu Perumalla


2 Answers

Just launch a new intent and clear the activities in the stack.

 Intent intent = new Intent(this, A.class);
 intent.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
 startActivity(intent);
like image 54
Slickelito Avatar answered Oct 27 '22 05:10

Slickelito


Use finish() method when you start Activity C. i.e.

Intent i = new Intent(ActivityB.this, ActivityC.class);
startActivity(i);
finish();
like image 38
wolverine Avatar answered Oct 27 '22 04:10

wolverine