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

  • Home
  • SEARCH
  • 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 6777807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:11:30+00:00 2026-05-26T16:11:30+00:00

Possible Duplicate: Android: ProgressDialog.show() crashes with getApplicationContext I want to have a progress dialog

  • 0

Possible Duplicate:
Android: ProgressDialog.show() crashes with getApplicationContext

I want to have a progress dialog to show up first then the toast. I want the progress dialog to load as long as the time delay chosen by the user like 15, 30, 60 seconds and no delay then the toast indicating that the message has been sent. How can I implement it? Where and how do I do it on my code?

Here’s my code:

btnSend.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String phoneNo = editTextRecipient.getText().toString();
                String message = editTextNewMessage.getText().toString(); 
                boolean split = false;

                final Toast toast = Toast.makeText(getBaseContext(), 
                         "Your message " + "\"" + message + "\"" + " is sent to " +"\""+ phoneNo+"\"", 
                          Toast.LENGTH_SHORT);

                Runnable showToastRunnable = new Runnable() {
                  public void run() {
                      toast.show();
        // Send button Listener

                  }
              };

                if (phoneNo.length()>0 && message.length()>0)  {
                    if (count == 0) {
                          handler.postDelayed(showToastRunnable, 0);
                      }
                      else if (count == 1) {
                          handler.postDelayed(showToastRunnable, 15000);
                      }
                      else if (count == 2) {
                          handler.postDelayed(showToastRunnable, 30000);
                      }
                      else if (count == 3) {
                          handler.postDelayed(showToastRunnable, 60000);
                      }
                }
                   // sendSMS(phoneNo, message, split); */
                else
                    Toast.makeText(getBaseContext(), 
                        "Please enter both phone number and message.", 
                        Toast.LENGTH_SHORT).show();
            }
        });        
    }
  • 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-26T16:11:31+00:00Added an answer on May 26, 2026 at 4:11 pm

    You can show progress dialog using following code

    private ProgressDialog dialog;
    public  void showProgress () {
        dialogSet = true;
        // prepare the dialog box
        //ProgressDialog 
        dialog = new ProgressDialog(this);
        // make the progress bar cancelable
        dialog.setCancelable(true);
        // set a message text
        dialog.setMessage("Please wait..");
        // show it
        dialog.show();
    
    }
    

    For cancelling the dialog, you should use dialog.cancel(). After cancelling dialog, you can display Toast

    Change your code like this

    Runnable showToastRunnable = new Runnable() {
                  public void run() {
                      dialog.cancel();
                      toast.show();
                  // Send button Listener
                  }
                 };
                if (phoneNo.length()>0 && message.length()>0)  {                                    
                    showProgress ();    
                    if (count == 0) {
                          handler.postDelayed(showToastRunnable, 0);
    
                      }
                      else if (count == 1) {
                          handler.postDelayed(showToastRunnable, 3000);
    
                      }
                      else if (count == 2) {
                          handler.postDelayed(showToastRunnable, 30000);
                      }
                      else if (count == 3) {
                          handler.postDelayed(showToastRunnable, 60000);
                      }
                }
                   // sendSMS(phoneNo, message, split); */
                else
                    Toast.makeText(getBaseContext(), 
                        "Please enter both phone number and message.", 
                        Toast.LENGTH_SHORT).show();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Updating progress dialog in Activity from AsyncTask I am developing my first
Possible Duplicate: Download a file with Android, and showing the progress in a ProgressDialog
Possible Duplicate: How to display progress dialog before starting an activity in Android? this
Possible Duplicate: Android Unknown Command 'crunch' I have been using eclipse just fine but
Possible Duplicate: R cannot be resolved - Android error The errors I have are
Possible Duplicate: Android Webview - Webpage should fit the device screen I want to
Possible Duplicate: MVC pattern in Android? I want to follow MVC architecture in Android
Possible Duplicate: Bluetooth support on Android Emulator I want to develop an Android Application
Possible Duplicate: Android - Application (apk) Maximum size I want to install an APK
Possible Duplicate: Lock the Android device programmatically I want to lock the screen through

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.