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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:47:18+00:00 2026-05-23T22:47:18+00:00

My app contained download button and whenever that button is pressed, I want some

  • 0

My app contained download button and whenever that button is pressed, I want some Progress Bar to show up so that the user knows there is something happening. What I really want to do is, whenever the Progress Bar is finished, I want some Toast to pop out. Can some one guide me with this? I would really appreciate it a lot. Thanks in advance!

Here is the code I am using:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final ProgressDialog dialog = new ProgressDialog(MyActivity.this);
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setMessage("Downloading...");
        dialog.setCancelable(true);
        dialog.setMax(200);
        dialog.setProgress(0);
        dialog.show();

        Thread t = new Thread(new Runnable(){
            public void run() {
                while(dialog.getProgress() < dialog.getMax())
                {
                    dialog.incrementProgressBy(1);
                    try{Thread.sleep(50);}catch(Exception e){/* no-op */}
                }
                dialog.dismiss();
            }
        });
        t.start();
    }
  • 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-23T22:47:19+00:00Added an answer on May 23, 2026 at 10:47 pm

    AsyncTask would be the easiest but if you are adamant on using your code you can add this snippet after the dialog.dismiss() statement.

      runOnUiThread(new Runnable(){
            public void run() {
                Toast.makeText(YourClassName.this, "task finished", Toast.LENGTH_LONG).show();  
            }
    
      }); 
    

    This is because the Toast must only be shown on the UI Thread.

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

Sidebar

Related Questions

I want to develop an app that can download a load of data at
I'm writing a small GUI app that contains some editor functionality, and something that
I am working on an Android app that uses the gdata-java-client to download documents
Here's my use case. I have a desktop app that can download from my
simple example of the problem: i have an app that can download backgrounds from
I have a flash app that needs to download a file, whose name contains
The app I'm working on has a self contained database. The only time I
I'm writing an app that contains the following tables: (1) employee_type, (2) employee and
I'm working on a Rails app that will contain information on a bunch of
Part of a complex query that our app is running contains the lines: ...(inner

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.