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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:36:40+00:00 2026-06-12T18:36:40+00:00

Working on an app in android I have used Asynctask class, Works fine when

  • 0

Working on an app in android I have used Asynctask class, Works fine when i tested on my Android device running on 2.3.5, but the problem i am facing is, same is not working for my tablet 4.0.4

While testing, got to know that prexecute() is being called but doInbackground() not being called, however doInbackground() is being called on device(2.3.5).

One of the reason i believe for the problem is that the processor of Tablet is much faster than that of device, so may be some threading issues, dats why, to tackle this, i have used some flags, and used Thread.sleep() in a do while loop so that when condition is true, it works, but no luck, i am stuck in the loop itself. Here is my code:

MyAsyncTask object = new MyAsyncTask (MainActivity.this);
runOnUiThread(new Runnable() {
    public void run() {         

        try {
            if (object.isReady() || !object.isStarting()) {
                return;
            }

            object.execute();

            do {
                Thread.sleep(1000);             
            } while (!object.isReady() && object.isStarting());

            if(!object.isReady()) { 
                return;
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }           
});

AsynctaskClass:

public class MyAsyncTask extends AsyncTask<Void, Void, Boolean>{

    private ProgressDialog dialog;
    private Context context;
    private boolean isStarting = false;
    private boolean isReady = false;


    public AsyncUpdatesofJquery(Context context) {
        this.context = context;
        isStarting = true;
        isReady = false;
    }

    public boolean isStarting() {
        return isStarting;
    }

    public boolean isReady() {
        return isReady;
    }

    @Override
    protected void onPreExecute() {

        isStarting = true;
        isReady = false;
        dialog = new ProgressDialog(context); 
        dialog.setMessage("Downloading Files, Please wait...");
        dialog.show();
    }

    @Override
    protected Boolean doInBackground(Void... params) {

        isReady = true;
        isStarting = false;
        downloadFiles(context); // my background task

        return true;
    }

    @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        context.startActivity(new Intent(context, NewActivity.class));
        dialog.dismiss();
        isReady = false;
        isStarting = false;

    }
}
  • 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-12T18:36:41+00:00Added an answer on June 12, 2026 at 6:36 pm

    The multi-threading model changed between 2.3.5 and 4.0.4. AsyncTask now defaults to having all subclasses in an application using the same thread (i.e. only one AsyncTask can run at a time!). It’s explained here:

    When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.

    If you truly want parallel execution, you can invoke executeOnExecutor(java.util.concurrent.Executor, Object[]) with THREAD_POOL_EXECUTOR.

    With that in mind, it could be that another AsyncTask is running in your app, thereby preventing this one from ever starting. That would explain why it works fine on your 2.3.5 device, but not your 4.0.4 tablet.

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

Sidebar

Related Questions

I have an app which was tested thoroughly and working fine on Android Gingerbread
I have made an android app which working fine. I implemented the Login functionality
I have created an app on local machine Android everything is working fine. Maps
I have an app on android market which was working fine on tab before.
I am working on the in app billing in android and I have tested
I am working on an Android App and I have used android FragmentPager tabs
I have an Android app that I had working a few months ago which
I am working on an android app and have to use remote database for
Working on an Android app with FB 4.6, I would like to have the
I'm working with an existing Android app and I need to have a dynamically

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.