views:

142

answers:

2

For some reason my onPostExecute() is not called after my AsyncTask finishes.

My class decleration:

public class setWallpaperForeground extends AsyncTask<String, Integer, Boolean>

My onPostExecute():

protected void onPostExecute(Boolean result)

Everything works fine, my doInBackground() completes successfully and returns a Boolean but then it just finishes.

Thanks

+1  A: 

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.

Romain Guy
I didn't have the @Override there. Looking at the example (http://developer.android.com/reference/android/os/AsyncTask.html) neither do they. Why must I have one over onPostExecute() but none of the others?
mlevit
It seems to work on the Emulator but not on the phone. When the background processes finish no Toast notification appears. The layout does look like it re-loads for some unknown reason. Any ideas?
mlevit
You don't have to have @Override, but it's a way to ensure you properly overrode the method.
Romain Guy
A: 

Did you start the task with execute() method? The onPostExecute wouldn't run if you just invoke the doInBackground.

Konstantin Burov