I have two AsyncTasks that I am using, one is called up after a dialog returns in the FragmentActivity and there is code after the .execute I call. The other .execute is called just in an if...else. The one called after another dialog returns, does what it is supposed to, it executes, on post execute it pops back the activity to the previous one and everything works.
The other the onPostExecute is never called. I did a break point in the doInBackground which executes and returns the null, just like the other one does but the onPostExecute never happens, is there some issue with having too many AsyncTasks in one FragementActivity, or too many calls to execute? I am stuck and hoping its something stupid I am just not seeing, so I am posting the code but I really cannot figure out why the onPostExecute never gets called in the AddEventWorker but does in the AddEventFromDialogWorker. The way I test the application it does so happen the AddEventFromDialogWorker gets called, works, and then anything to the AddEventWorker does not work (does do the doInBackground but not the onPostExecute).
Any ideas or avenues for me to try?
private class AddEventWorker extends AsyncTask<Void, Void, Void>{
protected void onPostExecute() {
getFragmentManager().popBackStack();
}
@Override
protected Void doInBackground(Void... params) {
mGoogleApi.addEvent(mSession, allGoogleAccounts.get(0).getGoogleCalendarName());
return null;
}
}
private class AddEventFromDialogWorker extends AsyncTask<String, Void, Void>{
protected void onPostExecute() {
Toast.makeText(mContext, "Event added to google calendar!", Toast.LENGTH_SHORT);
getFragmentManager().popBackStack();
}
@Override
protected Void doInBackground(String... params) {
mGoogleApi.addEvent(mSession, params[0]);
return null;
}
}
Your onPostExecute() method is never invoked because you are not overriding the base class’ onPostExecute() method. The signature should be protected void onPostExecute(Void result). If you used @Override the compiler would have told you about this issue 🙂