My problem is with deeplinking to my app. To be more specific, this also only happens when trying to open a deeplink to my app from Facebook Messenger with chat heads active.
Sometimes, when trying to return(not open, just return after messenger has overlayed app) to my app(which has only one activity) using a deeplink from FBMessenger the activity gets recreated. onCreate
method is called and a new instance of my activity is being created. The main problem is that this does not happen after the old activity is destroyed, I've added logs and first new activity's onCreate
gets called, and only after that old activity's onDestroy
gets called.
So why does Android try to create a new instance of my activity if it hasn't destroyed the old one yet?
Activity's launchMode
is set to singleTask
.
Edit: Also tried with launchMode
set to singleInstance
or singleTop
.
Edit 2: Found possible fix by adding android:documentLaunchMode="intoExisting"
to activity. Will do a few more tests tomorrow morning and post this fix as solution if everything works fine.