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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:34:23+00:00 2026-05-30T17:34:23+00:00

public class async extends AsyncTask<String, Integer, String>{ ProgressDialog prog; @Override protected void onPreExecute() {

  • 0
public class async extends AsyncTask<String, Integer, String>{
ProgressDialog prog;
@Override
protected void onPreExecute() {

    super.onPreExecute();
    prog=new ProgressDialog(async.this);//This is chowing error 
    prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    prog.setMax(100);
    prog.show();

}

    @Override
    protected String doInBackground(String... params) {
        for (int i = 0; i < 10; i++) {
        publishProgress(5);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }

@Override
protected void onPostExecute(String result) {

    super.onPostExecute(result);
    prog.dismiss();
}
@Override
protected void onProgressUpdate(Integer... values) {
    prog.setProgress(values[0]);
    super.onProgressUpdate(values);
}
}

The above code is producing the error:

the constructor ProgressDialog(AndroidasynctaskActivity.async) is
undefined

Why is this so? Can anyone please help me troubleshoot this?

  • 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-30T17:34:24+00:00Added an answer on May 30, 2026 at 5:34 pm

    As already mentioned, the reason this is happening is because the ProgressDialog constructor you’re using needs a Context object. Here’s one example of how you can do this.

    Modify your async class and add a single-argument constructor that accepts a Context object. Then modify the onPreExecute method to use said Context. For example:

    public class async extends AsyncTask<String, Integer, String>{
    
      private Context context;
      ProgressDialog prog;
    
      public async(Context context) {
        this.context = context;
      }
    
    
      @Override
      protected void onPreExecute() {
        super.onPreExecute();
        prog=new ProgressDialog(context); 
        prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        prog.setMax(100);
        prog.show();
      }
    
      // ...
    }
    

    Then to instantiate and run this AsyncTask:

    async mTask = new async(context);
    mTask.execute(params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a async task called within an activity: public class DownloadFile extends AsyncTask<String,
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
public class Main3 { public static void main(String[] args) { Integer min = Integer.MIN_VALUE;
public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
I have this sample code for async operations (copied from the interwebs) public class
public class MyClass { public int Age; public int ID; } public void MyMethod()
public class Address { public string ZipCode {get; set;} } public class Customer {
public class CovariantTest { public A getObj() { return new A(); } public static
public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x);

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.