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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:51:14+00:00 2026-06-12T00:51:14+00:00

I am using a Progress Dialog to show the progress of the activity.It starts

  • 0

I am using a Progress Dialog to show the progress of the activity.It starts running,but it is not dismissing even after calling removeDialog().This is the code:

public class MainActivity extends Activity {
    static final int PROGRESS_DIALOG = 0;
    ProgressDialog progressDialog = null;
    ProgressBar progressBar;
    MagickImage img = null;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        // InputStream stream = getResources().openRawResource(R.raw.app_notes);


        try {
            img = new MagickImage(new ImageInfo("/mnt/sdcard/image_background.jpg"));

//          setContentView(R.layout.main);
            Spinner s = (Spinner) findViewById(R.id.spinner);
            progressBar = (ProgressBar) findViewById(R.id.progressBar);


            ArrayAdapter adapter = ArrayAdapter.createFromResource(MainActivity.this,R.array.effects, android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            s.setAdapter(adapter);


            s.setOnItemSelectedListener(new OnItemSelectedListener() {

                public void onItemSelected(AdapterView<?> parent, View view,
                       int pos, long id) {
                    ProgressThread t = new ProgressThread(img, pos);
                    t.run();
                 //   progressDialog.dismiss();;

                }

                public void onNothingSelected(AdapterView<?> parent) {
                    // D       o nothing.
                }
            });

            ImageView iv = (ImageView) findViewById(R.id.imageView);
            iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            iv.setAdjustViewBounds(true);
            BitmapFactory.Options options=new BitmapFactory.Options();
            options.inSampleSize=8; //try to decrease decoded image
            options.inPurgeable=true; //if necessary purge pixels into disk
            options.inScaled=true; //scale down image to actual device density
            iv.setImageBitmap(MagickBitmap.ToBitmap(img));
        } catch (MagickApiException e) {
            e.printStackTrace();
        } catch (MagickException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        /*
         * TextView tv = new TextView(this);
         * tv.setText(DisplayImageMetaData.displayMagickImage(img));
         * setContentView(tv);
         */
    }

    protected Dialog onCreateDialog(int id, Bundle bundle) {
        switch (id) {
        case PROGRESS_DIALOG:
            /*
             * ProgressDialog dialog =
             * ProgressDialog.show(AndroidMagickActivity.this, "",
             * "Loading. Please wait...", true);
             */
            progressDialog = new ProgressDialog(MainActivity.this);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setMessage("Loading...");
            progressDialog.show(MainActivity.this,"", "Loading... Please Wait", true);
            return progressDialog;
            // return dialog;
        default:
            return null;
        }
    }


    /** Nested class that performs progress calculations (counting) */
    private class ProgressThread extends Thread {

        MagickImage img;
        int pos;

        ProgressThread(MagickImage image, int pos) {
            this.img = image;
            this.pos = pos;
        }

        public void run() {

            int effect = 0;
            MainActivity.this.showDialog(PROGRESS_DIALOG);
            new BackgroundAsyncTask().execute();
            switch (pos) {
            case 1:
                effect = NoiseType.UndefinedNoise;
                break;
            case 2:
                effect = NoiseType.UniformNoise;
                break;
            case 3:
                effect = NoiseType.GaussianNoise;
                break;
            case 4:
                effect = NoiseType.MultiplicativeGaussianNoise;
                break;
            case 5:
                effect = NoiseType.ImpulseNoise;
                break;
            case 6:
                effect = NoiseType.LaplacianNoise;
                break;
            case 7:
                effect = NoiseType.PoissonNoise;
                break;
            }
            Bitmap bitmap = null;
            try {
                ImageView iv = (ImageView) findViewById(R.id.imageView);

                MagickImage image = null;
                if (pos < 8)
                    image = img.addNoiseImage(effect);
                else if (pos == 9)
                    image = img.blurImage(5, 1);
                else if (pos == 10)
                    image = img.charcoalImage(5, 1);
                else if (pos == 11)
                    image = img.edgeImage(0);
                if (image != null) {
                      iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                      iv.setAdjustViewBounds(true);
                      BitmapFactory.Options options=new BitmapFactory.Options();
                      options.inSampleSize=8; //try to decrease decoded image
                      options.inPurgeable=true; //if necessary purge pixels into disk
                      options.inScaled=true; //scale down image to actual device density
                      bitmap = MagickBitmap.ToBitmap(image);
                      iv.setImageBitmap(bitmap);
                }

                MainActivity.this.removeDialog(PROGRESS_DIALOG);
            } catch (MagickException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            finally
            {
                MainActivity.this.removeDialog(PROGRESS_DIALOG);
            }
        }
    }    
}

I don’t know which mistake i am making.Please help me.Thanks in advance.

  • 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-12T00:51:15+00:00Added an answer on June 12, 2026 at 12:51 am

    You can do it using:

    progressDialog.dismiss();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to show dynamic progress dialog : public void
I'm using AsyncTask in my custom Dialog. AsyncTask works fine in activity, but inside
I am using asyncTask to show Dialog and then after few minutes then launch
Actually i have a problen while using progress dialog.The problem is not with the
Possible Duplicate: How to display progress dialog before starting an activity in Android? this
hey i want to display a loading progress using ProgressDialog on my aplication, but
I am working on displaying a progress bar using JQuery during a long running
When calling progressDialog = ProgressDialog.show(this, null, null, true); usually the developers wants to only
I am using an activity with the dialog theme set, and I want it
I am using AsyncTask to download files. There i implemented progress: //Updating progress dialog

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.