As explained by other users, your activity is created in the browser stack. You cannot prevent the browser from opening its own stack, but you can do the same configuration in your application.
In your browser-triggered activity, add the following to your manifest file:
android:allowTaskReparenting="true" android:launchMode="singleTask"
This will cause your activity to be created in the application stack (and not in the browser). This will bring your application to the forefront.
android: launchMode = "singleTop" will not work, because it prevents the creation of a new action only if this activity is on top of the stack, which is not the case since the browser is at the top. android: launchMode = "singleTask" ensures that no other instances are created whether they are on top or not.
If you set Intent.FLAG_ACTIVITY_NO_HISTORY with the above configuration, everything should work fine, regardless of whether the browser is previously open or not. In the worst case, the browser will be at the bottom of the stack, and if you continue to hit, you will end up in the browser instead of exiting the application.
Angrax
source share