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

  • Home
  • SEARCH
  • 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 5971235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:29:20+00:00 2026-05-22T20:29:20+00:00

I am using the AsyncTask and I am getting the following error in the

  • 0

I am using the AsyncTask and I am getting the following error in the onProgressUpdate method:

java.lang.IllegalStateException: The
specified child already has a parent.
You must call removeView() on the
child’s parent first. at
android.view.ViewGroup.addViewInner(ViewGroup.java:1970)
at
android.view.ViewGroup.addView(ViewGroup.java:1865)
at
android.widget.TableLayout.addView(TableLayout.java:418)

I know what this error means and how to resolve it. What I do not understand is why I am getting this error ONLY in debug mode. Adding a Thread.Sleep(1000) to the doInBackground method practically negates the issue, but I cannot add that for obvious performance reasons.
Here is the gist of what is happening in my AsyncTask:

 protected Void doInBackground(Void... params) {

    row1 = TableVisuals.createRow(context, flag);
    tv1 = TableVisuals.getTextView(context, Info[0]);
    row2 = TableVisuals.createRow(context, flag);
    tv2 = TableVisuals.getTextView(context, Info[1]);
    publishProgress(i,0);

}

protected void onProgressUpdate(Integer... value) {

table.addView(row1);
row1.addView(tv1, 0, span);
table.addView(row2);
row2.addView(tv2, 0, span);

dialog.setProgress(value[0]);

}

Keep in mind, the IllegalStateException does not happen in any one part of the above code. It is inconsistent in places, but almost always occurs. I wish there was a way for the background thread to wait for the UI thread other than Thread.Sleep() because it appears that it is adding views too fast in some cases.

  • 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-22T20:29:20+00:00Added an answer on May 22, 2026 at 8:29 pm

    Why not to move View creation outside the task or may be in onProgressUpdate because it is running on the UI-thread, and doInBackground is not.

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

Sidebar

Related Questions

I don't understand why I'm getting this error. I'm using AsyncTask to run some
The Android documentation has an example for using AsyncTask, in this example the DownloadFilesTask
I have a method that is executed using asyncTask with a progressdialog. After this
Im using HTC Hero with HTS sense. Im experience that sometimes AsyncTask not will
Using C#, I need a class called User that has a username, password, active
I am currently having trouble getting a value from an AsyncTask that gets data
I'm using AsyncTask s to fetch data in response to the user pressing a
Currently, I'm using AsyncTask to handle Http connection and retrieve data as JSON format.
I do have a problem working with my application. I am using AsyncTask class
I am using complex list item as following to lazy upload image i am

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.