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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:06:45+00:00 2026-06-04T18:06:45+00:00

I am displaying a progress bar using Async task class and simulatneously in parallel

  • 0

I am displaying a progress bar using Async task class and simulatneously in parallel operation , i want to retrieve a string array from a function of another class that takes some time to return the string array.

The problem is that when i place the function call in doing backgroung function of AsyncTask class , it gives an error in Doing Background and gives the message as cant change the UI in doing Background ..

Therefore , i placed the function call in post Execute method of Asynctask class . It doesnot give an error but after the progress bar has reached 100% , then the screen goes black and takes some time to start the new activity.

How can i display the progress bar and make the function call simultaneously.??plz help , m in distress

here is the code

package com.integrated.mpr;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Progess extends Activity implements OnClickListener{



    static String[] display = new String[Choose.n];
    Button bprogress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.progress);  
        bprogress = (Button) findViewById(R.id.bProgress);
        bprogress.setOnClickListener(this); 
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        switch(v.getId()){
        case R.id.bProgress:        
            String x ="abc";    
            new loadSomeStuff().execute(x);     
            break;
        }
    }

    public class loadSomeStuff extends AsyncTask<String , Integer , String>{

        ProgressDialog dialog;
        protected void onPreExecute(){
            dialog = new ProgressDialog(Progess.this);
            dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            dialog.setMax(100);
            dialog.show();
        }
        @Override
        protected String doInBackground(String... arg0) {
            // TODO Auto-generated method stub

            for(int i = 0 ;i<40;i++){
                publishProgress(5);

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            dialog.dismiss();
            String y ="abc";
            return y;
        }

        protected void onProgressUpdate(Integer...progress){

            dialog.incrementProgressBy(progress[0]);
        }

        protected void onPostExecute(String result){
            display = new Logic().finaldata();
            Intent openList = new Intent("com.integrated.mpr.SENSITIVELIST");
            startActivity(openList);    
        }
    }
}
  • 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-04T18:06:47+00:00Added an answer on June 4, 2026 at 6:06 pm

    You can’t dismiss the dialog in doInBackground() – even dismissing a dialog needs the UI task. Move dialog.dismiss() to onPostExecute() of the AsyncTask.

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

Sidebar

Related Questions

I am working on displaying a progress bar using JQuery during a long running
I am using following code, but my progress bar is not displaying in the
ui-1.7.3.custom.min.js for progress bar.. but it is only displaying in orange color.. how to
I'm having some trouble displaying a rotated progress bar. Ideally I would like to
I'm using Twitter4J and a WebView. A circular progress bar (spinner) is displayed in
I am calling a script using ajax. I want to show the progress of
There's a dropdown displaying 1-10 from where the user selects the number of textboxes
I'm displaying user messages through templates using RequestContext in Django, which gives access to
I have a little trouble with a progress bar since iOS 5 came out.
I have a basic bar chart I'm presenting in flot (5 bars, displaying the

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.