7

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?

Community
  • 1
  • 1
gookman
  • 2,527
  • 2
  • 20
  • 28
  • 1
    It's been long but did you happen to find a solution to this problem? I am stuck in a similar situation. – Purush Pawar Mar 13 '20 at 09:30
  • 1
    @PuruPawar sorry I have moved away from the project some time ago, but if I remember correctly the solution was to not use shared element transitions and just implement a custom transitions solution. If you only need scaling and translation it should be easy to do. – gookman Mar 14 '20 at 10:49
  • 1
    Thanks, @gookman. I was thinking about going all custom over this. – Purush Pawar Mar 16 '20 at 05:45

0 Answers0