我有一个AlertDialog
设置为bluetoothsocket.connect()
之前显示,这是一种阻止方法。但是,AlertDialog
直到bluetoothsocket.connect()
方法结束后才显示。Android AlertDialog不会显示,直到bluetoothsocket.connect()
myalertdialog.show();
// Dialog is not shown.
mybluetoothsocket.connect(); // This blocks and takes a few seconds to run.
// Dialog is shown.
什么可能导致此行为?
你说得对,阻塞代码不应该在UI线程上运行。正如你所提到的那样,我将它移到了一个AsyncTask中,它现在可以完美运行。谢谢!! – pcdangio