title: Android bluetooth Enabling going crazy
body: <p>Android Bluetooth enabling is going crazy. I am working on a chat type app which will populate the bluetooth devices (paired non-paired and discovered in range) into a  <code>ListView</code>. </p>
  
  <p>as soon as I switch on the bluetooth, the background code</p>
  
  <pre><code>ArrayOfDevices = btAdapter.getBondedDevices();
  if(ArrayOfDevices.size()&gt;0)//paired dev more than 0
  {
      for(BluetoothDevice device: ArrayOfDevices)
  {
      listAdapter.add(device.getName()+ "\n" +device.getAddress());
  }
  //for breadcast recievers and registering them//
  }
  </code></pre>
  
  <p>this listadapter is filled properly, but it needs bluetooth already switched on for this matter. 
  bluetooth code is:</p>
  
  <pre><code>        if(!btAdapter.isEnabled())
          {
              Toast.makeText(getApplicationContext(), "Enablingggggg the bluetooth device", 
                      Toast.LENGTH_SHORT).show();
              Intent iBlueEnabled = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
              startActivityForResult(iBlueEnabled, 1);
  }
  else // 
  
  
  //some code follows
  </code></pre>
  
  <p>The problem is that enabling the bluetooth is simple but problem arises when I have the code to follow after enabling the bluetooth. that code gets executed before the bluetooth is enabled properly (as it takes time).
  question of using a custom bluetooth adapter is out of reach for me. 
  Any solution from experts??? 
  thankyou in advance.</p>