title: How to redirect audio from android device to bluetooth speeker
body: <p>I am trying to redirect all the audio I play in my app to a bluetooth speaker. At first I pair the bluetooth device and then I try to 'say' to the audioManager, that all audio I play should be sent to the bluetooth speeker:</p>
  
  <pre><code>private final BluetoothAdapter _bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  
  public void pairBluetoothDevice(BluetoothDevice bluetoothDevice)
  {
      BluetoothSocket socket= bluetoothDevice.createInsecureRfcommSocketToServiceRecord( UUID.fromString( "0000111E-0000-1000-8000-00805F9B34FB" ) );
      socket.connect();
  
      _bluetoothAdapter.getProfileProxy( _appContext, _profileListener, BluetoothProfile.HEADSET );
  }
  
  private BluetoothProfile.ServiceListener _profileListener = new BluetoothProfile.ServiceListener()
  {
    public void onServiceConnected( int profile, BluetoothProfile proxy )
    {
       if ( profile == BluetoothProfile.HEADSET )
       {
          _bluetoothHeadset = (BluetoothHeadset) proxy;
          _bluetoothHeadset.startVoiceRecognition(_device);
  
          AudioManager audioManager = (AudioManager) _appContext.getSystemService(Context.AUDIO_SERVICE);
          audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
          audioManager.startBluetoothSco();
          audioManager.setBluetoothScoOn(true);
          audioManager.setSpeakerphoneOn(false); 
       }
    }
  
    public void onServiceDisconnected( int profile )
    {
       if ( profile == BluetoothProfile.HEADSET )
       {
          AudioManager audioManager= (AudioManager) _appContext.getSystemService(Context.AUDIO_SERVICE);
          audioManager.setBluetoothScoOn(false);
          audioManager.stopBluetoothSco();
          audioManager.setMode(AudioManager.MODE_NORMAL);
          audioManager.setSpeakerphoneOn(true); 
  
          _bluetoothHeadset.stopVoiceRecognition(_device);
          _bluetoothHeadset= null;
       }
    }
  };
  </code></pre>
  
  <p>When I play audio ...</p>
  
  <pre><code>_soundPool.play( _soundPoolMap.get( index ), streamVolume, streamVolume, 1, 0, speed );
  </code></pre>
  
  <p>... I hear nothing.</p>
  
  <p>Thanks for any hint :-)</p>