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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:27:54+00:00 2026-06-17T13:27:54+00:00

I want to display a dialog window after execution of a work, AND progress

  • 0

I want to display a dialog window after execution of a work, AND progress dialog should be displayed untill the work is finished.so i try to use thread in following code.

ProgressDialog dialog=new ProgressDialog(SampActivity.this);
                     dialog.setMessage("Please wait..");
                     dialog.setProgress(100);
                     dialog.setMax(5000);
                     dialog.show();
                     Thread progressing = new Thread() 
                       {
                         @Override
                         public void run()
                           {
                                try
                                        {
                                           Thread.sleep(5000);
                                           Looper.prepare();
                                         AlertDialog.Builder 

alertDialogBuilder = new AlertDialog.Builder(SampActivity.this);
                                     alertDialogBuilder.setMessage("finished");
                                     AlertDialog alertDialog = alertDialogBuilder.create();
                                     alertDialog.show();

                                     }
               catch (Exception e) 
               {
                   e.printStackTrace();
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(SampActivity.this);
                 alertDialogBuilder.setMessage("Unable to stop SAP.The connection is down.Please retry after sometime.");
                 AlertDialog alertDialog = alertDialogBuilder.create();
                 alertDialog.show();
               }

                       finally
                       {
                           dialog.dismiss();
                       }

                          runOnUiThread(new Runnable(){

                                                @Override
                                                public void run() {
                                                    if(dialog.isShowing())
                                                        dialog.dismiss();
                                                }
                                            });
                       }
                   };       
                 progressing.setPriority(Thread.MAX_PRIORITY );
                 progressing.start();

after running this program the program hangs.i dont know whats wrong in the code.
Please help me to figure it out.
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-17T13:27:55+00:00Added an answer on June 17, 2026 at 1:27 pm

    You cannot update the ui from non-ui thread…You can or use runOnUiThread to do the part that updates the ui:

    runOnUiThread(new Runnable() {
    public void run() {
        //display dialog
    }
    });
    

    Or better use an AsyncTask..

    private class MyTask extends AsyncTask<URL, Integer, Long> {
    
       private Context context;
    
       public MyTask(Context context) {
         this.context = context;
       }
    
       protected void onPreExecute() {
          progressDialog = ProgressDialog.show(context, "", "msg", true); 
       }
    
      protected Long doInBackground(URL... urls) {
           //do something
      }
    
     protected void onPostExecute(Long result) {
         progressDialog.dismiss();  
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use XmCreate{Error|Warning|Info}Dialog to display some message in screen in my SDL
i want to use facebook's fb:dialog tag to display a simple pop-up form for
I basically want to display a rectangle on a dialog window widget. Using another
I want to display and iframe into a jquery ui dialog. This iframe needs
I am having trouble creating a layout for a dialog I want to display
eHello everyone,the following is my code to display a jquery dialog window with a
I am using the Caliburn Micro Window Manager to display a dialog. I would
I want to display a custom alert dialog whose structure has been defined in
I want to display the alert dialog box to device screen size. I got
I want to display an alert dialog in my app. I am using fragments.

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.