In my application audio recorded in a Foreground service. I start recording after Bluetooth SCO is connected. Its working fine form Android KitKat to Nougat. But when I tried with Huawei Honor 8 (Android Oreo), audio is recording from phone microphone instead of Bluetooth headset microphone. When I tried on Google pixel 2, the recording not works at all. 

> 
> Start Bluetooth SCO
> 
> 
> 

```
am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
registerReceiver(new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
        Log.d(TAG, "Audio SCO state: " + state);
        if (AudioManager.SCO_AUDIO_STATE_CONNECTED == state) { 
            am.setBluetoothScoOn(true);
            unregisterReceiver(this);
            startRecord();
        }
    }
}, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED));
am.startBluetoothSco();

```

> 
> AudioRecord config
> 
> 
> 

```
final int RECORDER_SAMPLERATE = 8000;
final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_MONO;
final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;

int bufferSize = AudioRecord.getMinBufferSize(RECORDER_SAMPLERATE,
        RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING);
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
        RECORDER_SAMPLERATE, RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING, bufferSize);

```