Android SDK AsyncTask doInBackground not running (subclass)

You should checkout this answer: https://stackoverflow.com/a/10406894/347565 and the link to google groups it includes. I had a similar problem as you, still unclear why it is not working, but I changed my code like this and problem is gone: ASyncTask<Void,Void,Void> my_task = new ASyncTask<Void,Void,Void>() { … }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) my_task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[])null); else my_task.execute((Void[])null);

Android AsyncTask threads limits?

All AsyncTasks are controlled internally by a shared (static) ThreadPoolExecutor and a LinkedBlockingQueue. When you call execute on an AsyncTask, the ThreadPoolExecutor will execute it when it is ready some time in the future. The ‘when am I ready?’ behavior of a ThreadPoolExecutor is controlled by two parameters, the core pool size and the maximum … Read more

Ideal way to cancel an executing AsyncTask

Just discovered that AlertDialogs‘s boolean cancel(…); I’ve been using everywhere actually does nothing. Great. So… public class MyTask extends AsyncTask<Void, Void, Void> { private volatile boolean running = true; private final ProgressDialog progressDialog; public MyTask(Context ctx) { progressDialog = gimmeOne(ctx); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // actually could set running … Read more

Android: How can I pass parameters to AsyncTask’s onPreExecute()?

You can override the constructor. Something like: private class MyAsyncTask extends AsyncTask<Void, Void, Void> { public MyAsyncTask(boolean showLoading) { super(); // do stuff } // doInBackground() et al. } Then, when calling the task, do something like: new MyAsyncTask(true).execute(maybe_other_params); Edit: this is more useful than creating member variables because it simplifies the task invocation. Compare … Read more