Proper use of android.app.ProgressDialog [dismiss() vs hide()]
-
28-10-2019 - |
Pergunta
Can somebody please explain how android.app.ProgressDialog is properly used. Since, when I call hide() method, it says Only the thread which created the ui can touch it
. But dismiss() method removed the progress dialog. But after dismiss() method, calling show() does not properly show the progress dialog.
Solução
Do not use hide()
or dismiss()
outside UI thread. You must invoke these methods in UI thread.
To hide dialog from non UI thread you can use View.post
if you have any view or Activity.runInUiThread
.
More better use onPostExecute
or onCancel
for AsyncTask
class. Or Handler
as a general approach.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow