Shared transitions do not work when using FLAG_ACTIVITY_CLEAR_TOP

So, I have a rather complicated navigation system where I can finish the cycles between root activity and other actions. To avoid memory leaks, I should use Intent.FLAG_ACTIVITY_CLEAR_TOPwhen restarting root activity.

For transition between actions I use general transitions of elements (ImageViews), which work fine when switching from root activity to other actions (in this case I actually use Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).

The problem is restarting the main action from other activities. Intended use Intent.FLAG_ACTIVITY_CLEAR_TOPmakes the background flicker on the phone’s main screen (the root activity becomes completely transparent and you can see the main screen) while the transition continues.

Intent intent = new Intent(parent, RootActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(parent, imageView,     imageView.getTransitionName());

startActivity (intent, options.toBundle ());

In the root activity I have a fragment, so I have to call postponeEnterTransition()in onCreate, and I call startPostponedEnterTransition()in the listener the onPreDrawroot view of the fragments.

I can’t understand what the problem is. Is this a theme related issue, or is this some kind of bug in Android?

+4
source share

Source: https://habr.com/ru/post/1653805/


All Articles