2

I started to automate my Android app. It has a "Terms & conditions" screen. In that, if I click on "decline", my app will be closed.

How can I relaunch or restart my app within the same process?

Trinimon
  • 13,839
  • 9
  • 44
  • 60
Vaishnavi
  • 23
  • 4

1 Answers1

10

Try this:

// assuming this method is in a ActivityInstrumentationTestCase2 class
public void test_yourTest() {

    // do your testing

    Solo.sleep(1000);

    // killing all your Activities manually if it doesn't by itself anyway
    Solo.finishOpenedActivities();

    // relaunch your app by calling the same Activity as in the constructor
    // of your ActivityInstrumentationTestCase2
    this.launchActivity(TARGET_PACKAGE_ID, YourStartActivity.class, null);

    Solo.sleep(1000);

    // do your testing
}
JoachimR
  • 5,150
  • 7
  • 45
  • 50
  • Thanks. If you want to, head over to http://stackoverflow.com/questions/30096491/lifecycle-testing-with-robotium-killing-and-restarting-activity/30099143#30099143 and post your answer there. – serv-inc May 07 '15 at 11:18