I have a Robotium test for an Android application, which extends ActivityInstrumentationTestCase2. The test operates on a loop, randomly clicking on active views. I would like to verify at the start of each iteration which Activity is currently focused. This behavior is important for me because one of the buttons is capable of starting another Activity, making further actions in the loop not possible, since they refer to the Activity under test (this is when I stop the Robotium test).
I would like a generic solution that would work for any Activity, without the need to change the onDestroy() method. This solution must also work for when the Home button is pressed.