The app has MainActivity and NextActivity. User opens the app in MainActivity, then goes to NextActivity.
If user sent the app into background the system may kill the application process.
In logs I see that sometimes when user opens the app again next time the system restarts application process from NextActivity instead of MainActivity. Sometimes It causes one crash
I fixed the crash, but to test the fix I have to reproduce scenario when the application process is restarted from the last opened activity.
I checked and tried suggestions from this SOF questions:
Android Simulator: Easy way to simulate a process restart due to low memory?
Simulate killing of activity in emulator
Simulate low battery & low memory in Android
But every time when I kill the application process on next open I saw that the app restarted from MainActivity.
When I need to check such cases I use this adb command:
adb shell am kill <app_package_name>
and I do it in the following sequence:
If app handles restoring state correctly I see the screen from the first step with correct state if not I see incorrect state of the screen, another screen, crash etc.