It looks like you would be better off disabling postponeEnterTransition () in onCreate (or elsewhere) in your receive activity, inject all heavy init () after this call, and release the hold transition by explicitly calling startPostponedEnterTransition () after initialization is done. In the absence of a joint transition necessary to trigger activities such as DeepLink, etc., it will simply go straight to your heavy init without delay.
Here is the code:
Action A - initiates the transition of a common element.
Intent ActivityDemoOneBIntent = new Intent(ActivityDemo1A.this, ActivityDemo1B.class); String transitionName = getString(R.string.activityTransitionName); Bundle optionsBundle = getTransitionOptionsBundle(imageViewAnimated, transitionName); startActivity(ActivityDemoOneBIntent, optionsBundle);
Action B - βGetsβ the General Transition of an Element
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demo_1_b); postponeTransition(); // postpone shared element transition until we release it explicitly // Do all heavy processing here, activity will not enter transition until you explicitly call startPostponedEnterTransition() // all heavy init() done startPostponedTransition() // release shared element transition. This can be placed to your listeners as well. } private void postponeTransition() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { postponeEnterTransition(); } else { ActivityCompat.postponeEnterTransition(this); } } private void startPostponedTransition() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { startPostponedEnterTransition(); } else { ActivityCompat.startPostponedEnterTransition(this); } }
source share