I m facing this issue of creating multiple instance of same activity when app comes in foreground from background. Every time app goes in background then comes in foreground after sometime, new activity created without destroying old so the count increases by 1 every time.
while debugging with android studio, it is found that instance of application shows dead after remaining for sometime in background, after this dead state when app comes in background this issue happens.
Launch Mode is SingleTop with ClearTop
Logs in screenshots are stated as :
in activity oncreate ----> in oncreate function of activity
in oncreate ----> in oncreate function of fragment attached to activity
in onViewCreated ----> in onViewCreated function of fragment
For screenshots click on links below.
app open first tym and moved to background
Dead state is showing instead of app running in background, when it brought to foreground, new Activity created. and look at screenshot below