Reputation: 227
I have two activity (ACT 1 and ACT 2):
ACT1 contains the button "next" with the code:
case R.id.next:
Intent intent = new Intent(this, ACT2.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.startActivity(intent);
break;
}
ACT2 contains a button "back" no code for now.
so my problem I do not know what change in the button "next" and what to put in the button "back" to:
next: Open ACT2 if it is never open else go ACT2
back: back to ACT1
PS : I will not destroy "ACT2" if I go back a "ACT1", because I do not want to lose the contents entry
Upvotes: 0
Views: 688
Reputation: 4670
try this as per my suggestion..try like that.
// Write code in Next button click Event
Intent intent = new Intent(ACT1.this, ACT2.class);
startActivity(intent);
finish();
// Write code in Back button click Event
Intent intent = new Intent(ACT2.this, ACT1.class);
startActivity(intent);
finish();
Upvotes: 0
Reputation: 1199
From your description it seems u need to come back to act1 on back of act 2 and on next of act 1 to need to go to act 2 ....just start the activity i dont think u need that flag there
Upvotes: 1
Reputation: 19492
In the onClick() method of BACK use finish() method, this destroys the current Activity and moves to the previous opened activity.
Upvotes: 1