0

I am working on an application that has Activities A and B. If I navigate from A -> B, background the app then foreground the app Activity B is destroyed and I am brought back to Activity A.

Initially I thought that this was an issue of the Activity B's state not being restored when the app was brought into the foreground but after implemented onSavedInstanceState()/onRestoreSavedInstanceState() I am still seeing this issue.

Placing a breakpoint in the Activity B's onDestroy() shows that the ActivityThread.handleDestroyActivity() is being called immediately when the app is foregrounded without an attempt to restore the activity.

I am currently using android:LaunchMode="singleTask" in the AndroidManifest for ActivityA and android:LaunchMode="standard" for ActivityB. ActivityB is being launched from Fragment on ActivityA.

Does anyone know why Acitivty B does not persist after the app is backgrounded and foregrounded?

hlupi
  • 75
  • 5

1 Answers1

0

I was able to find an explanation for the behavior I was seeing in this post: Android: bug in launchMode="singleTask"? -> activity stack not preserved

Essentially if the activity uses launchMode=singleTask the task will be recreated each time the app is launched and the root activity will be relaunched. This effectively clears any activities sitting on top of Activity A from the taskstack.

Community
  • 1
  • 1
hlupi
  • 75
  • 5