0

I have an Activity which sets the exit transition as Explode, like this: (API >= 21)

...
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        getWindow().setExitTransition(new Explode());
    }
    setContentView(R.layout.activity_test);
    ...
}
...

When I start another Activity like this:

startActivity(intent,ActivityOptions.makeSceneTransitionAnimation(this).toBundle());

the explode transition appears. How ever, I want to play the explode transition when I press the back button(which finishes the activity), but it doesn't work out as I expected.

So is the exit transition just for entering the next Activity or what? What if the Activity is the leaf Activity(which starts no other Activity) in my app?

And:

  1. What should I do to play the explode transition when the leaf Activity is finishing?
  2. What should I do if I want to play a shared element transition to its parent Activity, but not the way in reverse?
teejoe
  • 673
  • 2
  • 6
  • 17

1 Answers1

0

i think this will help you to finishing the Activity with ExitTransition

 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        startActivity(homeIntent, ActivityOptions.makeSceneTransitionAnimation(MainActivity.this).toBundle());

    }
sivaBE35
  • 1,876
  • 18
  • 23