8

I've been using Android's overridePendingTransition method to animate my activity page transitions with great success. Example shown

startActivity(new Intent(GetTagActivity.this, MainActivity.class));
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

I have a situation that I need to "refresh" a page and desire a fade transition. Without going into the details, I can't use the StartActivity(...)method to call the refresh (which would allow for the animation call).

Using recreate()works perfect to "refresh" the page, however I haven't been able to add the transition animation. This hasn't worked.

recreate();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

nor this

recreate().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

Can fade animation (or any activity transition) be used with recreate()?

seekingStillness
  • 4,833
  • 5
  • 38
  • 68
  • What about `finish()` followed by `startActivity()`? – azizbekian Feb 26 '17 at 21:29
  • Any updates on this? I stumbled across same requirement. – gaurav414u Apr 04 '18 at 06:56
  • No update specifically to the question, however since this post, I have learned how to use activity flags in conjunction with onNewIntent that has allowed me to mimic recreate() with a startActivity() call and use animation. Doesn't work for every situation but is something to look into. – seekingStillness Apr 04 '18 at 11:47

1 Answers1

-3

you can user this (Kotlin code)

  override fun recreate() {
    finish()
    startActivity(Intent(this,this.javaClass))
    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);


}
Mohammad Rbabah
  • 456
  • 2
  • 10