pcdangio pcdangio - 1 year ago 87
Android Question

Android AlertDialog won't show until after bluetoothsocket.connect()

I have an

that is set to display before
, which is a blocking method. However, the
doesn't show until after the
method finishes.

// Dialog is not shown.
mybluetoothsocket.connect(); // This blocks and takes a few seconds to run.
// Dialog is shown.

What could be causing this behavior?

Answer Source

If your bluetoothsocket.connect() is blocking, which you said it is, you should put it out of the UI main thread. What you can do is put it inside an AsyncTask. Your myalertdialog.show() can be executed right before calling your AsyncTask. Then call myalertdialog.hide() in AsyncTask's onPostExecute().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download