Shared Element Transition when reopening existing Activity in stack Reorder To Front
Asked Answered
H

1

7

I have an Activity A from there I open Activity B, and pass the shared element to it. It animates the transition fine, but when I go back to Activity A and then go to Activity B again which is still in the stack using

intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

The shared element transition is not run.

With regular animations you call overridePendingTransition() in onNewIntent for the animations to run. https://stackoverflow.com/a/8327091

I tried calling startPostponedEnterTransition() in there but nothing happened.

This is my code to allow for transitions

void allowWindowTransitions(){
Window w = getWindow();
w.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);  

Code to start activity

intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    ActivityOptionsCompat options = ActivityOptionsCompat.
            makeSceneTransitionAnimation(this, sharedElement, "profile");

startActivity(intent, options.toBundle());

I have tried messing around with setSharedElementReturnTransition & setSharedElementReenterTransition but nothing happened.

Is there a way trigger shared element transition manually to get around this.

Hobbyhorse answered 16/10, 2015 at 10:45 Comment(2)
have you found the answer?Distort
If anyone has been stuck in this situation, I could really use some insights.Budge
S
-2

Not sure about Shared element transitions but you can override onNewIntent method to apply animations when activity comes in foreground.

@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.i(TAG, "onNewIntent: "); overridePendingTransition(R.anim.transition_enter_from_right, R.anim.transition_exit_to_left); } Hope this helps!

Scot answered 9/8, 2016 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.