Routing audio bluetooth headset
<p>I use this code for routing audio to headset - Galaxy 5 device 2.2. But this same code doesn't work in Android 2.3.3 Galaxy Y device!!! When I power on headset, the media sound stop working... </p>

<pre><code>@Override
public void onReceive(Context context, Intent intent) {

    Log.i(TAG,"onReceive - BluetoothBroadcast");

    localAudioManager = (AudioManager) context.getSystemService("audio");

    String TAG = "BluetoothReceiver";
    String ACTION_BT_HEADSET_STATE_CHANGED  = "android.bluetooth.headset.action.STATE_CHANGED";
    String action = intent.getAction();         

    if(action.equals(ACTION_BT_HEADSET_STATE_CHANGED))
    {           
        int extraData = intent.getIntExtra(EXTRA_STATE  , STATE_DISCONNECTED);

        if(extraData == STATE_DISCONNECTED){
            localAudioManager.setBluetoothScoOn(false);
            localAudioManager.stopBluetoothSco();
            localAudioManager.setMode(AudioManager.MODE_NORMAL);
            Log.i(TAG, "Bluetooth Headset Off " + localAudioManager.getMode());
        }else{              
            localAudioManager.setMode(0);
            localAudioManager.setBluetoothScoOn(true);
            localAudioManager.startBluetoothSco();
            localAudioManager.setMode(AudioManager.MODE_IN_CALL);
            Log.i(TAG, "Bluetooth Headset On " + localAudioManager.getMode());
        }
    }   
}
</code></pre>

<p>Dears, please help me. </p>

<p>Thanks!
Mateus</p>
