Does an AlertDialog.show()
start a new thread? I don't see any indication in the Android documentation that it does, and would like confirmation.
Specifically, I want to make sure that the OnDismiss()
callback occurs on the UI thread.
Does an AlertDialog.show()
start a new thread? I don't see any indication in the Android documentation that it does, and would like confirmation.
Specifically, I want to make sure that the OnDismiss()
callback occurs on the UI thread.
Short: No, it doesn't create a new thread and yes it runs in the ui thread.
Long: It should be running in the ui thread since it modifies ui stuff but you can create it from another thread and you will end having an exception. If you have a second thread you should do all the AlertDialog
calls from the ui thread using one of the different ways to communicating with the ui thread. For instance runOnUiThread
No. The AlertDialog is kicked off on the current Activity thread. Anything you want to do in the background would need to be done on a seperate thread ( Thread, AsyncTask, etc.). When dismissing the dialog, you indeed need to call the dismiss from the Activity thread.
AFAIK it does not. There is no reason why it would. But to be sure you can inspect the source code.