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

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

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

}

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:

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