Reputation: 157
In my main activity, i set this override method to improve my animation activity :
overridePendingTransition(R.anim.pull_in_from_right, R.anim.pull_out_to_left);
In my second activity, i set onBackPressed() method to the main activity :
public void onBackPressed()
{
Intent backToMain = new Intent(this, MainActivity.class);
startActivity(backToMain);
super.onBackPressed();
}
It go back well, with the animation, but when I close the main activity that back from the second activity, the first main activity launched, still exist.
How to resolve this problem ? Thanks for your kindness response.
Upvotes: 3
Views: 4642
Reputation: 1681
You can just add one override method
@Override
public void finish() {
super.finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
Upvotes: 1
Reputation: 34285
In your second activity, you don't have to create new intent to go back to main activity.
public void onBackPressed(){
//you can do your other onBackPressed logic here..
//Then just call finish()
finish();
}
@Override
protected void onPause(){
super.onPause();
overridePendingTransition(R.anim.your_exit_animation_one, R.anim.your_exit_animation_two);
}
public void onBackPressed(){
//you can do your other onBackPressed logic here..
//Then just call finish()
finish();
}
Upvotes: 14