I am playing around with Lollipop sceneTransitionAnimations
.
To get it to work you need to implement getWindow().setExitTransition()
+ getWindow().setReenterTransition()
in the calling activity's onCreate
,
and getWindow().setEnterTransition()
+ getWindow().setReenterTransition()
in the called activity's onCreate
.
Then, when you call startActivity
you have to pass a Bundle
to that function that you obtain by calling ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle()
.
This works fine. However I need to start an activity using startActivityForResult
. This function only takes an Intent
and a requestCode
, but no Bundle
. Putting the bundle into the intent using putExtras
did not work.
How do I get these nice Lollipop transitions to work when I want to use startActivityForResult
?
EDIT as I was asked for code:
I am inside a Fragment, I have a list of items. When an item is clicked I start another activity.
Intent intent = new Intent(context, otherActivity.class);
Bunde bundle = null;
if (android.os.Build.VERSION.SDK_INT >= 21)
bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle();
now here come the two distinctions. This one works:
getActivity().startActivity(intent, bundle);
The Fragment does not offer this function, so I have to use its parent activity's - hence the getActivity()
.
This one does not work:
intent.putExtras(bundle);
startActivity(intent);