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 8445473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:40:12+00:00 2026-06-10T09:40:12+00:00

During many of my tests, my app is running AsyncTasks that access the database

  • 0

During many of my tests, my app is running AsyncTasks that access the database and cannot be cancelled. At the end of my tests, I close my database, delete it, then reopen it so I have a fresh database fixture.

The problem is that when the AsyncTasks happen to still be running during the time when the test is closing and deleting the database, I’ll get a runtime exception in the code. This couldn’t ever happen in the production code because the database is never closed in production.

Robotium has a test helper method called finishOpenedActivities that I use in my test teardown method. If there were some way to modify the finishOpenedActivities to ensure that all child threads (AsyncTasks specifically) were finished as well, that would be tremendously helpful. Otherwise I probably have to go implement checks for cancelled in all my AsyncTasks just to support reliable testing.

Is there were some way to wait until all child threads (AsyncTasks specifically) are finished?

  • 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-10T09:40:14+00:00Added an answer on June 10, 2026 at 9:40 am

    There is a getStatus() method according to the docs. You just need a reference to the AsyncTask.

    AsyncTask<Void, Void, Void> yourAsyncTask = new AsyncTask<Void, Void, Void>() {
    
        @Override
        protected Void doInBackground(Void... arg0) {
            // your async code           
    
            return null;
        }
    
    };
    
    if (yourAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
        // What ever you need to do if still running ex.
    
        yourAxyncTask.cancel();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the installation of my app, I want to create a PostgreSQL-Database and some
During Session Start, one has access to the Request object. How about Session End,
I have an NSManagedObject that has a to-many relationship to another NSManagedObject. During creation
In some my project I notice that during executing unit tests under VSTS2008 its
During many, sometimes inundating, debugging sessions using DDD, I stumble upon loops. And I
During compilation process many errors are thrown on the screen. To start resolving them
(Approximately) how many more bits of data must be transferred over the network during
std::swap() is used by many std containers (such as std::list and std::vector ) during
During our efforts to design InApp Billing for our Android App, we came up
Can you deploy a Rails3 app using Bundler's Gemfile WITHOUT running bundle install ...

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.