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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:19:27+00:00 2026-06-09T14:19:27+00:00

In my android, I want to show a message box with no way to

  • 0

In my android, I want to show a message box with no way to quit it, and while its showing, another process needs to run (in my case an email sending function). Then after the email is finished sending, the alert box needs to close.

This is what i got so far, but it’s not working…

Can anyone help?

    AlertDialog.Builder alertDialog = new Builder(this); // create an alert box
    alertDialog.setTitle("Sending...");
    alertDialog.setMessage("Please wait while your details and image is being sent to x.");

    alertDialog.show(); // show the alert box
    Reusable_CodeActivity.send_email(gmailAC, gmpassword, get_all_details(), image_path, this);

    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { // define the 'OK' button
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        } 
    });
  • 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-09T14:19:28+00:00Added an answer on June 9, 2026 at 2:19 pm

    I’m not sure about the email-sending part, but I can help you make the message box like you want to.

    If you remove the following code:

    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { // define the 'OK' button
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        } 
    });
    

    Then the dialog will display with no buttons, and if you add .setCancelable(false) it will not be dismissed until you tell it to, using alertDialog.cancel();

    Here’s an example (modified from one of my dialogs):

    AlertDialog.Builder builder = new AlertDialog.Builder(this); // Create the dialog object
            builder.setMessage(R.string.dialog_disclaimer_text)  // I use a reference to a string resource - it's good practice instead of using hardcoded text
                   .setIcon(android.R.drawable.ic_dialog_info)   // Here I specify an icon to be displayed in the top corner
                   .setTitle(R.string.dialog_disclaimer_title)
                   .setCancelable(false) // This one makes the dialog stay until the dismiss is called
    
                   .create().show(); // Show the dialog
    

    This code will display a dialog with text, which will not disappear until the activity calls builder.dismiss(); – which you’d then have to implement in some sort of a listener, or callback once the sending is complete.

    Update

    Looking at the other answer, this is probably how your code should look like (thanks to iturki)

    private class SendEmailTask extends AsyncTask<Void, Void, Void> {  
        AlertDialog.Builder alertDialog; // Define the AlertDialog builder object so it can be used/adressed across the entire class
    
        protected void onPreExecute() {
           //Show the dialog first
           alertDialog = new Builder(context);
           alertDialog.setTitle("Sending...")
                      .setMessage("Please wait while your details and image is being sent to x.");
                      .setCancelable(false)
                      .show();
        }
        protected void doInBackground(Void... params) {
           //Send Email Code
           Reusable_CodeActivity.send_email(gmailAC, gmpassword, get_all_details(), image_path, this);
        }
    
        protected void onPostExecute(Void result) {
           //Dismiss the dialog 
           alertDialog.dismiss();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show such popup in android. Quick Action Dialog is the way
I'm developing an Android application. Is there any way to show a message on
I want to show a button at the end of an Android list view.
I want to create an Android application that show the sales report from SQL
I want to consume a webservice and show that answer in tabhost on android.How
I want to display a message box with an OK button. I used the
I want to show message and play sound on viewpager when page selected. I
I want when i enter some area my android app automatically show me a
I am designing a project in phonegap with android. i want to show the
I am new to Android development. I want to show user notification even when

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.