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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:53:17+00:00 2026-05-26T20:53:17+00:00

I got some concerns about AsyncTask that I could not clarify when reading the

  • 0

I got some concerns about AsyncTask that I could not clarify when reading the documentation.

My app main Activity runs several AsyncTask’s when it’s created. These AsyncTask’s mostly download data or retrieve data from the DB.

  1. If I go to a different Activity, will the AsyncTask’s created on
    this one continue executing? Or will they stop working and leave the
    task half done? If so, will they go on somehow when getting back to
    this activity?
  2. In order to start one of the activities from the
    one that is running the AsyncTask’s, I need one of the AsyncTask’s
    to be fully executed. How do I set this constraint? Could you show
    me some sample code of this, please?

Thanks

  • 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-05-26T20:53:17+00:00Added an answer on May 26, 2026 at 8:53 pm

    If I go to a different Activity, will the AsyncTask’s created on this one continue executing? Or will they stop working and leave the task half done? If so, will they go on somehow when getting back to this activity?

    Yes, it will continue to run. This can be a bit of a double-edged sword as it will typically also hold on to the Activity instance, causing it to live beyond its onDestroy() callback, which is not ideal. If the task you are running does not have the same lifecycle needs as the Activity itself, it may be better placed into a Service.

    In order to start one of the activities from the one that is running the AsyncTask’s, I need one of the AsyncTask’s to be fully executed. How do I set this constraint? Could you show me some sample code of this, please?

    There are way too many ways to do this, many depending on the architecture of your application, to provide specific sample code…but here are a few higher level ideas. Since AsyncTask provides a simple callback method on the main thread (onPostExecute) when the task execution is complete, you can set a flag at that point. Or perhaps simply check for the existence of whatever data the AsyncTask is retrieving from any code where the Activity would be launched. Again, a Service would provide good context for this, as multiple Activities could connect to the service and check the task status before moving forward.

    Another option, depending on your application, is to have the result of the task dumped into a ContentProvider. ContentProviders include a nice interface for notifying observers of changes without resorting to global Broadcast Intents.

    HTH

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

Sidebar

Related Questions

Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I am new to asp.net and have got some concerns about the bloated viewstate
I got some legacy code with that caption spread out as comment almost in
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I got some files, after an egrep command, like egrep -l -r '(this|that|those)' *
I got some binary files containing integers. Is there some nice Unix command, that
It seems that I've finally got to implement some sort of threading into my
I've got a java applet that loads some pre-installed native code extensions to display
I've got the feeling that the answer is yes, and that's not restricted to
Good morning. As the title indicates, I've got some questions about using python for

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.