Reputation: 28188
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.
Upvotes: 1
Views: 294
Reputation: 80340
AFAIK it does not. There is no reason why it would. But to be sure you can inspect the source code.
Upvotes: 0
Reputation: 93153
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
Upvotes: 2
Reputation: 14600
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.
Upvotes: 0