Fix flakiness of testOnActivityResultAfterStop.

Sometimes the LaunchForResultActivity won't goes to stopped but
resumed directly, that could happen when ResultActivity idled on
server side and LaunchForResultActivity is animating, so the
status of LaunchForResultActivity is stopping.
Since ResultActivity is resumed, it would request to finish
itself, so LaunchForResultActivity would receive result then
resumed without entering stopped.

To minize possible lifecycles while testing, ensure the
LaunchForResultActivity was stopped before ResultActivity finish
itself.

Bug: 127741025
Fixes: 150298829
Test: atest pass over 200+ times.
Test: run atest for lifecycle package.
Change-Id: Ie68e0a8fc9050a416af05afcc9de093302996d9a
2 files changed