So I have a pretty complicated navigation system where I can end up with cycles between the root activity and other activities. In order to avoid memory leaks I have to use Intent.FLAG_ACTIVITY_CLEAR_TOP
when starting the root activity again.
To transition between activities I am using shared element transitions (ImageViews), which work fine when going from the root activity to other activities (in this case I am actually just using Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
).
The problem is when restarting the main activity from other activities. Using Intent.FLAG_ACTIVITY_CLEAR_TOP
in the intent causes the background to flicker to the phone home screen (the root activity becomes completely transparent and you can see the home screen) while the transition is ongoing.
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 onPreDraw
listener of the fragments root view.
I can't figure out what the issue can be. Is this a theme related problem or is it some bug in Android?