For some reason my onPostExecute()
is not called after my AsyncTask
finishes.
My class decleration:
public class setWallpaper
After having the same problem and none of these answers helped me, I found out that my UI thread was blocked (I used a CountDownLatch.await()) and therefore the onPostExecute()
method that is supposed to be called by the UI thread was never called.
Did you start the task with execute()
method? The onPostExecute
wouldn't run if you just invoke the doInBackground
.
I had the same behaviour, and the cause was that I have been posting a lot of messages as a progress inside doInBackground with following code:
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
// .. some UI updates
}
});
this must have overloaded main thrad message queue, and caused long delay before onPostExecute would get called. The solution was to post only once every second.
For me it was user error. I was ending the AsyncTask by invoking cancel(true) on it and not reading the documentation closely enough to know that onPostExecute is not called in this case, onCancelled is.
If your params of onPostExecute(Param param)
don't match the one you defined with extends AsyncTask<...,...,Param>
and you didn't use the @Override
annotation, it will never be executed and you don't get a warning from Eclipse.
Note to myself:
Just always use the @Override
annotation and Eclipse will help you.
in Eclipse: Right-click in code > Source > Override/Implement Methods
Did you create your AsyncTask on the UI thread? Also add an @Override annotaiton on your onPostExecute() method to make sure you declared it correctly.