Working on my AsyncTask I wonder why I should use the onPostExecute()‘s parameter, when I can just use a class level instance variable in my AsyncTask class to share data between doInBackground() and onPostExecute().
Both work, but are there any pro’s and con’s to each approach?
Edit: when I say ‘instance variable’, I’m talking about a private instance variable in the AsyncTask extended class. When the class dies, the instance variable dies too.
Well, it may reduce the probability of memory leak, since you do not hold a reference to your object at class level, but only it those AsyncTask methods.
It will also eliminate the synchronization problems, as @nico_ekito mentioned