Android Question How to preserve and restore last activity shown?

JohnC

Expert
Licensed User
Longtime User
I am seeing some strange behavior...

I have two activities: A and B.

A opens activity B using:
B4X:
StartActivity("B")

After B is displayed, the user can press the back button, and A will be displayed again.

But, if when B is being displayed, I instead press the "home" button, the screen will properly go to my home screen, and I will see in the log that B was "paused".

But, if I then tap on the app's shortcut icon to launch it again, activity A will be shown, not B which was the last currently shown activity.

Does anyone know why the app won't return to it's last active state of showing B?

P.S. I also have this in the manifest to make sure only one copy of the app is running:

B4X:
SetActivityAttribute(main, android:launchMode, "singleInstance")
 

JohnC

Expert
Licensed User
Longtime User
Thanks! That seemed to fix it, but I remember I needed to add that line in the manifest because I was having problems with multiple instances of my app running in memory (or something related to this)....lets see if that comes back.
 
Last edited:
Upvote 0
Top