I have the following Activities in my stack:
A , B , C, D
I want to relaunch B in order to get this stack:
A , B\'
here when you use this code the its take you on activity B. in B you Press backbutton the its take you on A.
Intent fromDtoB = new Intent(this,B.class);
fromDtoB.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(fromDtoB);
FLAG_ACTIVITY_CLEAR_TASK: If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.
FLAG_ACTIVITY_CLEAR_TOP: If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.