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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:03:09+00:00 2026-05-26T13:03:09+00:00

I have created an asynchronous task like this: private class LongOperationcheckall extends AsyncTask<String, String,

  • 0

I have created an asynchronous task like this:

private class LongOperationcheckall extends AsyncTask<String, String, String> {

    @Override
    protected String doInBackground(String... params) {
        String result="Start";
        try
        {
            Looper.myLooper().prepare();
            // Looper.loop();

            // TODO Auto-generated method stub
            for(int k=0;k<13;k++)
            {
                checkall();
                this.publishProgress("Show the dialog");

                //count++;
            }

            result="Success";
            checkallcomp++;

            OnscanComplete();
        }
        catch(Exception ex)
        {
            checkallcomp++;
            OnscanComplete();
        }
        return result;
    }

    @Override
    protected void onProgressUpdate(String... values) {
        super.onProgressUpdate(values);
        Log.i("Progress", "Progressincheck");
    }

    protected void onPostExecute(String params ) {
        Log.w("all Check",params);

        // Execution of result of Long time consuming operation
    }
}

I have added code,

Looper.myLooper().prepare();

to call to this task as

taskAllcheck = new LongOperationcheckall();
taskAllcheck.execute();

The fourth time when I click on start button the fourth time, it gives the exception

Can’t create handler inside the thread inside thread which not called looper.prepare

Only, when I run in the device it executes OK in the emulator, but after add this line, the error comes as only one looper may be created per thread when I click on the start button for the fourth time and call taskAllcheck.execute();.

  • 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-26T13:03:10+00:00Added an answer on May 26, 2026 at 1:03 pm

    Please think of the asynchronous thread as a UI thread that has a inbuilt handler to update your UI. No matter what, it is a thread. So now that is cleared, I don’t see where you have actually written the checkall() function. The check all function needs to be a local methodology for the asynchronous task to call in the background. It cannot be a method in your main class. If that is the case, there is no point of having a asynchronous task. So please add the checkall() function to your asynchronous task.

    Next, there is no need of the looper in the asynchronous task. The handling of the data is taken care of by:

    this.publishProgress(“Show the dialog”);

    Please make sure that you pass in anything that you want. Either an int, string, boolean, array or anything and everything can be handled in this. So make wise use of the implementation.

    Now, make the inside the onProgressUpdate() correspondingly and hence also please check that if you want something from the UI thread to be executed, such as a methods or something. That can be done in this method.

    Now make the changes I have told you. Please get back to me and I will be in a better position to work with you. If we can pinpoint the problem. Take care.

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

Sidebar

Related Questions

I have a class that I've created to allow asynchronous sequential execution of tasks,
I have created an Asynchronous WebClient request inside a class as follows: public class
I have created a C# class file by using a XSD-file as an input.
I have followed this tutorial http://netbeans.org/kb/docs/websvc/gs-axis.html and successfully created the web service. When i
I have this piece of code to make an asynchronous HTTP request: public static
I have created a servlet 3.0 to explore asynchronous request processing: @WebServlet(name=MyTest, urlPatterns={/MyTest}, asyncSupported=true)
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside

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.