AsyncTask onPostExecute never gets called

I had a similiar problem just now. I was extending AsyncTask<Integer,Integer,Integer> and my onPostExecute method looked like:

protected void onPostExecute(int result)

This seemed OK to me, but then again I’m more of a .NET guy than a Java guy.
I changed it to:

protected void onPostExecute(Integer result)

because for some reason Java thinks there is a difference between int and Integer?

I think that your problem is that you’re declaring the return type as void in your:

extends<Void,Void,Void>

That means no params, no progress and no result. If you want to execute something when it’s done, I think you need to give it some kind of value like and integer or a boolean.

If you change your extends to:

<Void,Void,Integer>

Now your passing no params, not publishing any progress, but are returning a value. Change your onPostExecute method to accept an Integer:

protected void onPostExecute(Integer result)

Then change the return in your doInBackground method to something like:

return 1;

Then it should execute for you.

Leave a Comment