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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:32:24+00:00 2026-06-18T23:32:24+00:00

So i am trying to launch a progress dialog from an async task. in

  • 0

So i am trying to launch a progress dialog from an async task.

in my main activity i am invoking the async task like so:

new OCRScanAsyncTask(getApplication().getApplicationContext()).execute();

also tried:

new OCRScanAsyncTask(getBaseContext()).execute();

my asyncTask looks like this:

public class OCRScanAsyncTask extends AsyncTask<String, Integer, Boolean> {

    /* (non-Javadoc)
     * @see android.os.AsyncTask#doInBackground(Params[])
     */
    private ProgressDialog progressDialog;
    private String TAG ="OCRAsyncTask";
    private String IMAGE_PATH = Environment.getExternalStorageDirectory() + "/bcCardReader/tmp/tmpCrd.jpg";
    public static final String DATA_PATH = Environment
            .getExternalStorageDirectory().toString() +"/bcCardReader/tmp/";

    private String lang = "eng";
    private Context context;


    public OCRScanAsyncTask(Context c){
       Log.v(TAG, "*****************CONSTRUCTING");
        context = c;
        progressDialog = new ProgressDialog(context);
    }
    @Override
    protected void onPreExecute(){

        super.onPreExecute();
        Log.v(TAG, "pre exe");
        progressDialog.setTitle("Please Wait");
        progressDialog.setMessage("Performing Character Recognition");
        progressDialog.setIndeterminate(false);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setCancelable(false);
        progressDialog.show();

    }
............

my error looks like this:
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-18T23:32:26+00:00Added an answer on June 18, 2026 at 11:32 pm

    bad window token on progressDialog in async task

    Most likely is problem with Context variable. So my first suggestion is replace your line

    new OCRScanAsyncTask(getApplication().getApplicationContext()).execute();
    

    with

    new OCRScanAsyncTask(YourActivityName.this).execute();
    

    Note: I recommend to you to show progressDialog before you will start AsyncTask.

    ProgressDialog pd = new ProgressDialog(this); // or YourActivityName.this
    pd.setMessage("some message");
    pd.show();
    AsyncWorker w = new AsyncWorker();
    w.execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to launch the Main Activity from a broadcast receiver. Can anyone
I'm trying to launch an intent from an activity class: Intent i = new
I'm trying to launch an activity from a custom lisview. I have hoded the
I am trying to launch a dialogue from a non activity java class. Can
I am trying to launch a XPage(web) mobile application from a email(Lotus traveller). When
I'm trying to launch a website url in a new tab using python in
I am trying to launch an existing MS Access database (Access 2010) from a
I'm trying to launch another application from C# application, is there a way to
Trying to launch and pass tel. no. to skype by this code from my
I'm trying to launch a save dialog in my windows RT app when someone

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.