How to stop code execution while waiting for Wifi and Bluetooth adapters to enable in Android?
<p>I had to manually turn on the network adapters in my program, and on Android this takes a while for the hardware to power up, up to a second.</p>

<pre><code>//turn on network adapters
wifiManager.setWifiEnabled(true);
bluetoothAdapter.enable();

while(wifiManager.getWifiState()!=WifiManager.WIFI_STATE_ENABLED | bluetoothAdapter.getState!=BluetoothAdapter.STATE_ON)

   ; //no code here, just waiting for adapters to enable

//continue execution
getDeviceInfo();
</code></pre>

<p>The above method I'm using now is not elegant at all, the CPU is locked-up in the while loop. Any ideas how to implement this in a better way?</p>
