I have MainActivity that contain a button to launch SecondActivity. If am on second activity & move the app to background then bring it to foreground immediately & then press the back button it closes the app instead of showing MainActivity.
When I relaunch the app by pressing the app icon it shows me SecondActivity & again when I press back button it closes the app. For the normal flow have to kill the app first then reopen the app. If I don’t kill the app whenever I open it it will launch SecondActivity.
Facing issue on Android 12.
Launching the SecondActivity through intent without setting any flags.
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
If I directly press the back button on SecondActivity without taking the app in background then its works normally i.e on press of back button it shows the MainActivity.
Issue occurs only when I put the app in background then bring it to foreground & press the back button.
Please suggest the solution. Thanks.