title: Bluetooth enabling disrupts broadcastreceiver
body: <p>My app is designed to append all scanned Bluetooth devices to a <code>textview</code>.  This works great if the phones Bluetooth is on.  However, if my app checks to see if the phones Bluetooth is off and turns it on if it is off, then start my the discovery process my <code>broadcastreciever</code> does not pick up an event and so my <code>textview</code> does not populate.  Any help is appreciated!</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_blue_tooth_main);
  
      txtResults = (TextView) this.findViewById(R.id.txtResults);
      mBlueToothAdapter = BluetoothAdapter.getDefaultAdapter();
      if (!(mBlueToothAdapter.isEnabled())) {
          mBlueToothAdapter.enable(); 
  
      }           
  
      mBlueToothAdapter.startDiscovery();
  </code></pre>
  
  <p>MY RECEIVER:</p>
  
  <pre><code>public static class BlueToothBroadcastReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          BluetoothDevice device = intent
                  .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
  
          blueToothName = device.getName();
          blueToothAddress = device.getAddress();
          blueToothClass = device.getBluetoothClass();
          blueToothBondState = device.getBondState();
          GetBondStateStr(blueToothBondState);
          blueToothUUIDS = device.getUuids();
  
          paramsBlueTooth
                  .add(new BasicNameValuePair("Name: ", blueToothName));
          paramsBlueTooth.add(new BasicNameValuePair("Address: ",
                  blueToothAddress));
          paramsBlueTooth.add(new BasicNameValuePair("Class: ", String
                  .valueOf(blueToothClass)));
          paramsBlueTooth.add(new BasicNameValuePair("Bond State: ",
                  blueToothBondStateStr));
          paramsBlueTooth.add(new BasicNameValuePair("UUIDS: ", String
                  .valueOf(blueToothUUIDS)));
  
          showBlueToothData();
  
      }
  </code></pre>
  
  <p>ShowBlueToothData():</p>
  
  <pre><code>    private void showBlueToothData() {
          StringBuilder results = new StringBuilder();
  
          results.append("-----BLUETOOTH DEVICE INFORMATION-----\n");
          results.append("Name: " + blueToothName + "\n");
          results.append("Address: " + blueToothAddress + "\n");
          results.append("Class: " + blueToothClass + "\n");
          results.append("Bond State: " + blueToothBondStateStr + "\n");
          results.append("UUIDS: " + blueToothUUIDS + "\n");
  
          txtResults.append(new String(results));
          txtResults.append("\n");
      }
  </code></pre>