Search code examples
androidtransitionandroid-lifecycleshared-element-transition

Why is onActivityReenter not called?


I override method

override fun onActivityReenter(resultCode: Int, data: Intent?) {
    super.onActivityReenter(resultCode, data)
}

for shared-element-transition. However, when i place debug on this method, I see it has never been called when comeback from another activity. How to use it ?

enter image description here

enter image description here


Solution

  • 2 Conditions for this method working First: Using ActivityOptions when startActivity

    startActivityForResult( Intent(this, TestActivity2::class.java), 1000, ActivityOptions.makeSceneTransitionAnimation(this, fab, "hien").toBundle())

    Second: Have to call setResult method before go back