title: How to automatically test onResume behaviour by calling onDestroy using Robotium?
body: <p>I am using Robotium to functionally test an Android app. I'd like to test the onResume behaviour after onDestroy has been called. 
  <a href="https://stackoverflow.com/questions/7838197/testing-onpause-ondestroy-using-robotium">This post</a> hints on using Instrumentation, but i can't get it to work.
  I have included the following, but this fails with an IllegalStateException.
  Is it possible to destroy the app and restart it?</p>
  
  <pre><code>public class MainActivityFunctionalTest extends ActivityInstrumentationTestCase2&lt;MainActivity&gt; {
  private Solo solo;
  
  public MainActivityFunctionalTest() {
      super(MainActivity.class);
  }
  
  public void testActionList() {
      getInstrumentation().callActivityOnDestroy(solo.getCurrentActivity());
      ...
  }
  </code></pre>
  
  <p>Results in the following exception:</p>
  
  <pre><code>java.lang.IllegalStateException: Must be called from main thread of process at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1373) at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1825) at android.app.Activity.performDestroy(Activity.java:5171) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1109) at nl.handypages.trviewer.test.MainActivityFunctionalTest.testActionList(MainActivityFunctionalTest.java:81) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214) at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199) at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
  </code></pre>