Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable supportFinishAfterTransition when backing out from an activity

Tags:

android

I have an activity I animate to with a transition animation, like this:

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, transitionStr);
ActivityCompat.startActivity(activity, intent, options.toBundle());

However, when I go back, I don't want the animation to run in inverse. Is that possible? I'm using AppCompatActivity from appcompat-v7:23.1.1.

like image 645
Michael Eilers Smith Avatar asked Mar 16 '16 03:03

Michael Eilers Smith


2 Answers

If you never want to have that transition back to the parent activity, use

finish();

You can wrap it around a condition if you sometimes want to the transition on the way back to the parent activity. An example use case would be to disable the transition when an interstitial ad was displayed:

if (interstitialAdWasDisplayed) {
  finish();
} else {
  finishAfterTransition();
}
like image 181
Bruno Carrier Avatar answered Nov 15 '22 09:11

Bruno Carrier


A possible duplicate of Overriding Transition

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

With this piece of code, you can override the finish animation of the current activity.

like image 37
Göktay K. Avatar answered Nov 15 '22 10:11

Göktay K.