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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:25:48+00:00 2026-06-15T19:25:48+00:00

Below is an async class i created that i am trying to implement a

  • 0

Below is an async class i created that i am trying to implement a dialog on execute and a Toast on complete.

How ever no toast or dialog are ever showing up.

my asykTask:

public class EmailPictureService extends HTTPRequestAsyncTask {
    Context context;
    ProgressDialog dialog;
    public EmailPictureService(Context context){
        this.context = context;
        //dialog = new ProgressDialog(context);
    }
    @Override
    protected void onPreExecute() {

        super.onPreExecute();
    }   

    @Override
    protected String doInBackground(Object... params) {
        Log.v("Start EMAIL SERVICE","START YOPPPPPPPPPPPPPPPPPPPPPP!");
        dialog = new ProgressDialog(context);
        dialog.setMessage("Sending...");
        dialog.setIndeterminate(true);
        dialog.show();
        HTTPInvoker invoker = new HTTPInvoker();
        HttpResponse response = null;

        EmailPicture emailPicture = new EmailPicture();
        emailPicture.setDeviceType("TABLET");
        emailPicture.setStoreId((String)params[1]);
        emailPicture.setNotificationType("E");
        emailPicture.setRecipientName((String)params[2]);
        emailPicture.setRecipientEmail((String)params[3]);

        String jsonString = JSONConverter.toJson(emailPicture);
        response = invoker.invokePOSTFileService((String)params[0], jsonString, (File[])params[4]);
        return parseHttpResponse(response);
    }

    @Override
    protected void onPostExecute(String result) {
        String msg = "";
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
        if (result != null) {
            JSONObject jsonObject = null;
            long errorCode = 0;
            try {
                jsonObject = new JSONObject((String) result);
                errorCode = jsonObject.getLong("errorCode");
                if(errorCode<1){
                    msg ="Success, your picture has been sent";
                }else{
                    msg = "Sorry, there was an error sending your picture. Please try again later.";
                }
                Log.i(Constants.TAG, "Error Code...." + errorCode);
                Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
                toast.show();

            } catch (JSONException e1) {
                Log.i(Constants.TAG, "Exception...." + e1);
                Toast toast = Toast.makeText(context, "Failure: "+e1, Toast.LENGTH_SHORT);
                toast.show();
                e1.printStackTrace();
            }
        }

    }

}

how i call it from my activity:

new EmailPictureService(this).execute(url,storeID,cusName, cusEmail, new File[]{file});

my log
enter image description here

  • 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-15T19:25:49+00:00Added an answer on June 15, 2026 at 7:25 pm

    You should not attempt to access the UI from doInBackground(). The purpose of AsyncTasks and doInBackground() is avoid bogging down the UI thread… Instead you should preform the UI work in the appropriate methods: onPreExecute(), onProgressUpdate(), onPostExecute(), etc

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

Sidebar

Related Questions

Let's say I have an async controller like that below ~ public class HomeController
How does async JMS work? I've below sample code: public class JmsAdapter implements MessageListener,
I created a server hub in an asp.net application like below public class Calc
How do I implement an async method in Python DBus? An Example below: class
Below is my Async class public class GetBitMapFromURL extends AsyncTask<String, Integer, String> { byte[]
I have two async classes in my application which you can see below class
I have the below class I want to unit test: public class MyClass {
I have a AsyncCommandHandlerDecorator<TCommand> and LifetimeScopedCommandHandlerDecorator<TCommand> as shown below: public class AsyncCommandHandlerDecorator<TCommand> : ICommandHandler<TCommand>
I have a class that has a number of methods that follow the below
While doing an async mongodb query like the one in the below class how

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.