Reputation: 5
Let say there is an activity stack A -> B -> C -> D, from activity D, I want to finish it and go to activity A. It's ok to destroy activity B and C, btw. activity D can be accessed from activity A / B / C. So If I call activity D from B (A -> B -> D), I still want to go to activity A.
Upvotes: 0
Views: 60
Reputation: 6732
Do like this:-
Call the Intent on the onBackpressd() method.It will go on that activity which you want. Like:-
@Override
public void onBackpressd() {
super.onBackpressd();
Intent intent = new Intent(ActivityD.this, ActivityA.class);
intent.putExtra("param", param); //optional
startActivity(intent);
finish();
}
Hope this will help you.
Upvotes: 0
Reputation: 326
In Activity D:
Intent intent = new Intent(ActivityD.this, ActivityA.class);
intent.putExtra("param", param); //optional
startActivity(intent);
finish();
Upvotes: 1