Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9318717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:11:58+00:00 2026-06-19T03:11:58+00:00

I am using Robotium to functionally test an Android app. I’d like to test

  • 0

I am using Robotium to functionally test an Android app. I’d like to test the onResume behaviour after onDestroy has been called.
This post 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?

public class MainActivityFunctionalTest extends ActivityInstrumentationTestCase2<MainActivity> {
private Solo solo;

public MainActivityFunctionalTest() {
    super(MainActivity.class);
}

public void testActionList() {
    getInstrumentation().callActivityOnDestroy(solo.getCurrentActivity());
    ...
}

Results in the following exception:

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:12:00+00:00Added an answer on June 19, 2026 at 3:12 am

    Well you have two issues here, the first issue is that the instrumentation callactivityondestroy methods require you to call it from the main thread. see runOnUiThread usage tips for details on how to do this.

    The second issue is that (and i might be wrong here) is never suppose to go from onDestroy to onResume http://developer.android.com/reference/android/app/Activity.html says that after ondestroy the activity is literally destroyed. You would have to create a new instance of the activity to get another onResume. with you could do by launching your activity again. I suppose you could do it your way but im not sure how valid it would be, if you wanted to do it in such a way, just call the onResume in the same way as onDestroy as noted in the question i linked to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I writing test cases for Android apps using Robotium. One of my test cases
I'm testing my android app using robotium , I have used fragments in my
I'm using Robotium for some test automation for an Android application. It's great, but
I'm just trying to test an android application using Robotium. The issue I have
I am trying to automate android app(Relocation services)using robotium. In this app there are
I'm running an automated test in Eclipse using Robotium (running it as an Android
I am using Robotium to test android application. Below is my piece of code.
So I am trying to write automation test using Robotium for Android I have
I am running a test using Robotium on an android emulator. When I run
I have a Robotium test cases that I would like to run nightly using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.