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

The Archive Base Latest Questions

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

I am using ProgressDialog to display a spinner while a Thread is running. When

  • 0

I am using ProgressDialog to display a spinner while a Thread is running. When the thread is finished, the dialog is removed from the view and another Activity is pushed onto the stack. The problem is, the dialog is not disposed of. When I go back to the Activity (pop the stack) and return to the previous Activity, the same instance of the ProgressDialog is being called (when asked to show dialog).

Create the dialog:

protected Dialog onCreateDialog(int id) { 

 progDialog = new ProgressDialog(this);
 progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
 progDialog.setMessage("Searching for ..." + txtPart.getText().toString());
 // Start thread            
 progThread = new AcmXmlSearchHelper(handler, txtTitle.getText().toString(), txtPart.getText().toString(), txtSection.getText().toString(), this);
 progThread.start();
 return progDialog;

}

Show the dialog:

showDialog(getProgressId()); 

Dismiss the dialog:

dismissDialog(getProgressId());  

The easy solution is to call a ProgressDialog (showDialog()) with a unique id. However, I don’t think this is good use of memory. I could have a number of Dialogs hanging around in memory. How do I make sure the object is disposed?

Thx

  • 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-25T15:26:53+00:00Added an answer on May 25, 2026 at 3:26 pm

    Creating a nested AsyncTask class would probably clear things up for you:

    private static class MyTask extends AsyncTask<Void, Void, Void> {
    
               protected void onPreExecute() {
                   // Show dialog here - note: showDialog is depricated.
               }
    
                protected Void doInBackground(Void... unused) {
                        // do the stuff that's in your thread here.
                        return null;
                }
    
                protected void onPostExecute(Void unused) {
                        // Dismiss dialog here - note: dismissDialog is depricated.
                }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using below code from one of my activity to start another Intent
In a long-running operation, I'm showing a popup dialog (created from ProgressDialog to prevent
In my android application i am playing videos using video view.While the video is
Possible Duplicate: How to display progress dialog before starting an activity in Android? this
I'm using a background thread to read some data from my database.The data that
Actually i have a problen while using progress dialog.The problem is not with the
I'm trying to make a simple ProgressDialog appear while my AsyncTask is fetching data.
I am writing an activity, that loads data from a server and displays it
I have a main activity that launches a child activity using the following code:
I have an Activity that retrieves information from a remote server and displays it

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.