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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:03:10+00:00 2026-06-03T10:03:10+00:00

I have a long process running inside AsyncTask but it might need to confirm

  • 0

I have a long process running inside AsyncTask but it might need to confirm something from user while processing. I know how I can show a confirm dialog but how can I retrieve the output and keep wait till use confirms?

this.runOnUiThread(new Runnable() {
            public void run() {
               boolean output = ConfirmUser(message);
            }
        });
  • 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-03T10:03:11+00:00Added an answer on June 3, 2026 at 10:03 am

    I will say that it is bad idea. If you need a confirmation from user, you better split your AsyncTask in two parts: do some part first, then inside onPostExecute() you can show dialog (because it is running on ui thread) and, depending on user action, launch second AsyncTask.

    If you still want to do it one AsyncTask, you can do it like this:

    final BlockingQueue<Boolean> queue = new ArrayBlockingQueue<Boolean>(1);
    this.runOnUiThread(new Runnable() {
        public void run() {
            // Assuming you have ConfirmUser method which returns boolean
            queue.add(ConfirmUser(message));
        }
    });
    
    
    Boolean result = null;
    try {
        // This will block until something will be added to the queue
        result = queue.take();
    } catch (InterruptedException e) {
        // deal with it
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where user requests to do a long running process. I
I have a long-running process that must run every five minutes, but more than
I have a long running process and I need it to launch another process
I have a transactional grails service which is doing some (long running) processing. While
I have an application for PDAs with a long running process, and I'm getting
I have a long running io process that I would like to be able
I have a long-running process where, due to a bug, a trivial/expendable thread is
So you have a long running process, perhaps with a progress bar, and you
I have a python web application that needs to launch a long running process.
I want a long-running process to return its progress over a Queue (or something

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.