I am facing the issue with displaying progressbar onItem selected in option menu.
My code is here:
case R.id.mnuLogout:
showDialog(Constants.PROGRESS_DIALOG);
closeOptionsMenu();
if(MyApp.IsLoggedOut())
handler.sendEmptyMessage(Constants.LOGOUT);
else
handler.sendEmptyMessage(Constants.ERROR_MSG);
Progressbar is displayed after completion of IsLogged method.
You’re calling
get()right after theAsyncTaskas executed and lose asynchronous behavior because this method waits until task is finished. You should add all the code in try/catch block toAsyncTask.onPostExecute()method and also dismiss the dialog from this method.And I don’t think you need to send messages to the handler. The
dispatchLogoutFinished()is executed on the UI thread, so there’s no need for synchronization.