Reputation: 469
how can i call an activity from stack instead of launching new instance ? here is a scenario :
Upvotes: 1
Views: 108
Reputation: 6598
Try to use FLAG_ACTIVITY_REORDER_TO_FRONT. For example:
Intent intent = new Intent(BActivity.this, AActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
From javadocs:
public static final int FLAG_ACTIVITY_REORDER_TO_FRONT
Added in API level 3If set in an Intent passed to Context.startActivity(), this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running.
For example, consider a task consisting of four activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then B will be brought to the front of the history stack, with this resulting order: A, C, D, B. This flag will be ignored if FLAG_ACTIVITY_CLEAR_TOP is also specified.
Upvotes: 0
Reputation: 47945
If I get your point correctly you can simple exit your activity B and C with finish();
.
So if you ActivityC finishes and also ActivityB the ActivityA should come to the front, which should be that what you want.
Upvotes: 1