Reputation: 11766
After doInBackground
finishes what it does, onPostExecute
not get called. and if I try to publish a progress, onProgressUpdate
not get called too.
I recreated an asyncTask that does nothing in the background but logging a text and yet both methods not get called.
Here is my code
public class MyAsyncTask extends AsyncTask<Object, Integer, Void> {
@Override
protected Void doInBackground(Object... params) {
Log.d("MyAsyncTask","doInBackground");
publishProgress(1);
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.d("MyAsyncTask","onPostExecute");
super.onPostExecute(result);
}
@Override
protected void onProgressUpdate(Integer... values) {
Log.d("MyAsyncTask","onProgressUpdate");
super.onProgressUpdate(values);
}}
and here is how I call it
new MyAsyncTask().execute();
Upvotes: 2
Views: 19169
Reputation: 11766
I was using flurry jar in the project, and by removing it and re-adding it to the project, every thing worked fine... I don't know why but that's what solved it for me.
Upvotes: 1
Reputation: 3283
Execute your task on main/UI thread:
new MyAsyncTask().execute("Test");
Asynctask:
public class MyAsyncTask extends AsyncTask<String, Integer, String> {
protected void onPreExecute() {
Log.d("MyAsyncTask","MyAsyncTask Started");
}
protected String doInBackground(String... params) {
Log.d("MyAsyncTask",params[0] + " in background.");
publishProgress(params[0]);
return null;
}
protected void onProgressUpdate(Integer... values) {
Log.d("MyAsyncTask","onProgressUpdate - " + values[0]);
}
protected void onPostExecute(String result) {
Log.d("MyAsyncTask","onPostExecute " + result);
}
}
Upvotes: 1