I have been trying to implement the new Lollipop activity and shared elements transitions during a few days following the steps from Alex Lockwood awesome blog posts. But now I'm facing a bit of a problem.
My application uses a DrawerLayout for navigation, but I can also launch some of the activities when clicking other views and buttons. I have set correctly all the Enter, Reenter, Return and Exit transitions for all the activities as well as calling:
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(activity, getSharedViewsPairs(activity)).toBundle());
for the shared elements between those activites.
If I launch the activities for the first time, the transitions work up well. My problem comes when I try to launch/resume an activity that has already been called before but that now is paused and lives still on the activity stack. When I try to bring this activity to the foreground, then there is no transition.
I also have to say that I set to all my activities the Intent flag FLAG_ACTIVITY_REORDER_TO_FRONT so that in case they have been already launched before, I don't fresh launch them again. Could this have anything to do with it? Am I missing some method that needs to be called when resuming activities that have been launched previously with transitions?
Code for preparing the activity transitions:
public static void requestTransitionsAnimations(Activity activity) {
if(MaterialAnimations.isAnimationSupported()){
Transition transition = TransitionInflater.from(activity).inflateTransition(R.transition.material_transitions);
activity.getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
activity.getWindow().setAllowEnterTransitionOverlap(true);
activity.getWindow().setAllowReturnTransitionOverlap(true);
activity.getWindow().setEnterTransition(new Explode());
activity.getWindow().setReenterTransition(new Explode());
activity.getWindow().setReturnTransition(new Explode());
activity.getWindow().setExitTransition(new Explode());
activity.getWindow().setSharedElementsUseOverlay(true);
activity.getWindow().setSharedElementEnterTransition(transition);
activity.getWindow().setSharedElementReenterTransition(transition);
activity.getWindow().setSharedElementExitTransition(transition);
activity.getWindow().setSharedElementReturnTransition(transition);
}
}
as