title: Turn bluetooth on and wait for intent?
body: <p>I have an Android App that requires some Bluetooth settings; see below:</p>
  
  <pre><code>if (!Constants.mBluetoothAdapter.isEnabled()) {
      Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
      startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
  }
  while (!Constants.mBluetoothAdapter.isEnabled()) {
      try {
          Thread.sleep(100);
      } catch (InterruptedException e) {
          System.exit(1);
      }
  }
  if (Constants.mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
      Intent discoverableIntent = new
          Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
          discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
          startActivity(discoverableIntent);
  }
  while (Constants.mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
      try {
          Thread.sleep(100);
      } catch (InterruptedException e) {
          System.exit(1);
      }
  } // do some stuff with bluetooth
  </code></pre>
  
  <p>This seems like a hack to me, and it only works if the user selects "yes". I'm pretty sure I need to be waiting on a result from these intents. How is that done?</p>