I don't know the very details of async task,
I recently used async task in my project to get some data from server side and update my UI according to the result,I implimented a progress dialog in the usual way and dismissid it in my onPostExicute method like this
@Override
protected void onPostExecute(ArrayList<StationSlots> result) {
try {
publishProgress(100);
WizardStep4.retStationSlots = result;
if (WizardStep4.this.dialog != null) {
WizardStep4.this.dialog.dismiss();
}
} catch (Exception e) {
}
}
But I found some codes done the same thing but perfoming the action on a ui thread like this
@Override
protected void onPostExecute(ArrayList<StationSlots> result) {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
publishProgress(100);
WizardStep4.retStationSlots = result;
if (WizardStep4.this.dialog != null) {
WizardStep4.this.dialog.dismiss();
}
} catch (Exception e) {
}
}
});
}
I like to know which one is the best method and what are the differences ?