Saturday, March 26, 2016

How to disable supportFinishAfterTransition when backing out from an activity

Leave a Comment

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.

2 Answers

Answers 1

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.

Answers 2

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(); } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment