How can I add an animation to the activity finish() How can I add an animation to the activity finish() android android

How can I add an animation to the activity finish()


I override pending transition just after calling finish();

In my case, I have done it to avoid transitions.

finish();Details.this.overridePendingTransition(R.anim.nothing,R.anim.nothing);

Order is important :)


This question has already answered but the most efficient way to put an animation while exiting from an activity is by overriding the "finish()" method of the related activity:

@Overridepublic void finish() {    super.finish();    overridePendingTransition(R.anim.hold, R.anim.slide_out_bottom);}


I would suggest to use isFinishing() method to configure the animations at onPause instead of calling finish()

@Overrideprotected void onPause() {    super.onPause();    if (isFinishing()){        overridePendingTransition(R.anim.activity_slide_in, R.anim.activity_slide_out);    }}