I observed that if I open some apps installed in my phone via Google Play's 'Open Now' button the app will open as normal, if I navigate to another Activity inside the app, then pressed home, then go to phone's launcher, open the app through there. It will start a new task -- I believe -- because the App's launcher activity has resurfaced. If I press back, I will then be in the second Activity -- which is the last Activity in the foreground when I launched the app from Google Play. Is there a way to avoid this? I'm expecting to see the second activity in this scenario. I want to have the same task whether my app is launched from the Launcher or Google Play store.
I found out that a lot of apps in the Playstore has this behavior. One good example is the Zomato app and for reference my app is Shake Eat Off
I've been experimenting the android:launchMode in the Manifest with no luck.
I tried setting singleTask to the root activity and `singleTop to the second Activity
I also tried adding android:alwaysRetainTaskState="true" to the root Activity.
I also tried setting singleTask to the root Activity and singleInstance to the second Activity
So to explain more the chain:
Google Play App Page -> Open Now -> Root Activity -> Second Activity(now foreground). Press home, Click App Icon. At this point, The root Activity is now again showing (But I'm expecting to see the second Activity because it's the last activity on the foreground). Press back -> The Second Activity will resurface.