I have 2 activities with a transition. Everything works fine when opening B from A and coming back if I do not rotate my phone.
But if I rotate the phone, I get this when pressing back from B:
As you can see (downloading the gif and looking frame by frame helps):
- the exit animation seems to run fine, but the size of the image isn't scaled down to the correct size
- activity A is still there, the size of the action bar's text is the small landscape size
- then I have a big black blink
- then A is recreated but the shared elements are missing
This is happening on a Nexus 5X, but on a Samsung Galaxy Note 5 it's working fine. If I disable the shared element transition, everything works fine.
What can I be missing here? Here is the code used to start B:
View toolBar = findViewById(R.id.toolbar);
List<Pair<View, String>> pairs = new ArrayList<>();
pairs.add(Pair.create(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
pairs.add(Pair.create(toolBar, toolBar.getTransitionName()));
pairs.add(Pair.create((View)viewerFragment.getImageView(), viewerFragment.getImageView().getTransitionName()));
//noinspection unchecked
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(CaptureDetailsActivity.this, pairs.toArray(new Pair[pairs.size()])).toBundle();
Intent intent = new Intent(this, LocalViewerActivity.class);
[...]
ActivityCompat.startActivityForResult(this, intent, REQUEST_LOCAL_VIEWER_ACTIVITY, bundle);