I play with Lollipop sceneTransitionAnimations.
To make it work, you need to implement getWindow().setExitTransition()+ getWindow().setReenterTransition()in the calling activity onCreate, and getWindow().setEnterTransition()+ getWindow().setReenterTransition()in the called activity onCreate.
Then, when you call startActivity, you must pass Bundlethis function, which you get by calling ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle().
It works great. However, I need to get started with startActivityForResult. This function accepts only Intenta requestCode, but not Bundle. Attaching a beam to an intent using putExtrasdid not work.
How do I make these nice Lollipop transitions work when I want to use startActivityForResult?
EDIT because I was asked to enter the code:
I am inside a fragment, I have a list of items. When an item is clicked, I trigger another action.
Intent intent = new Intent(context, otherActivity.class);
Bunde bundle = null;
if (android.os.Build.VERSION.SDK_INT >= 21)
bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle();
now two differences come. It works:
getActivity().startActivity(intent, bundle);
A fragment does not offer this feature, so I need to use its parent activity - hence getActivity().
This work is not :
intent.putExtras(bundle);
startActivity(intent);