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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:17:45+00:00 2026-06-17T11:17:45+00:00

I know this question has been asked multiple times, but I have an apparently

  • 0

I know this question has been asked multiple times, but I have an apparently clean code that just doesn’t work, giving me no Exceptions or anything.

I have a trivial one-button Activity (MainActivity). The button in it calls an AsyncTask in order to send an email in the background. I tried to do what I guess it’s a pretty common thing: show a ProgressDialog when the task starts and dismiss it when it ends. To do so I put the above-mentioned code into AsyncTask.onPreExecute() and AsyncTask.onPostExecute().
I thought the problem was in the Context provided to the dialog constructor, but I created a simple constructor for my AsyncTask to which I pass the application context. I added a simple Toast to debug, but it doesn’t show up neither…

Here’s the code for the button onClick method:

public void onClick(View v) {
    new Sender(this).execute("args");
}

And here’s the code for the task:

private class Sender extends AsyncTask<String, Void, Void> {
    private ProgressDialog progDialog;
    private Context context;

    public Sender(Context context) {
        this.context = context;
    }

    @SuppressWarnings("unused")
        protected void onPreExecute(Void... params) {
        Toast.makeText(this.context, "Sending...", Toast.LENGTH_SHORT).show();
        progDialog = ProgressDialog.show(this.context, "Sending", "Picture is being sent...", true);
    }

    protected Void doInBackground(String... mailSubj) {
        // some code that works
        return null;
    }

    @SuppressWarnings("unused")
    protected void onPostExecute(Void... v) {
        progDialog.dismiss();
        Toast.makeText(MainActivity.this, "Mail sent", Toast.LENGTH_SHORT).show();
    }
}

Where did I go wrong?

  • 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-17T11:17:46+00:00Added an answer on June 17, 2026 at 11:17 am

    Your progress dialog not show up because you don’t override onPreExecute(). Add @Override annotation to your onPreExecute(), see what happens. onPreExecute takes no arguments.

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

Sidebar

Related Questions

I know that this question has been asked multiple times already , but I
I know this question has been asked multiple times but all the answers seem
I know this flavor of question has been asked multiple times, but I've spent
I know this question has been asked multiple times before, but none of the
I know this question has been asked multiple number of times and i have
I know this question has been asked multiple times, but nobody has been able
I know this question has been asked a zillion times, but I still feel
I know this question has been asked before numorous times but they seem to
I know this question has been asked countless of times. But none of them
Yes, I know this question has been asked a lot of times, but I

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.