private void updateAudioDeviceState(boolean hasWiredHeadset){
  audioDevices.clear();
  if (hasWiredHeadset) {
    audioDevices.add(AudioDevice.WIRED_HEADSET);
  }
 else {
    audioDevices.add(AudioDevice.SPEAKER_PHONE);
    if (hasEarpiece()) {
      audioDevices.add(AudioDevice.EARPIECE);
    }
  }
  Log.d(TAG,"audioDevices: " + audioDevices);
  if (hasWiredHeadset) {
    setAudioDevice(AudioDevice.WIRED_HEADSET);
  }
 else {
    setAudioDevice(defaultAudioDevice);
  }
}

private void updateAudioDeviceState ( boolean hasWiredHeadset ) { audioDevices . clear ( ) ; if ( hasWiredHeadset ) { audioDevices . add ( AudioDevice . WIRED_HEADSET ) ; } else { audioDevices . add ( AudioDevice . SPEAKER_PHONE ) ; if ( hasEarpiece ( ) ) { audioDevices . add ( AudioDevice . EARPIECE ) ; } } Log . d ( TAG , "audioDevices: " + audioDevices ) ; if ( hasWiredHeadset ) { setAudioDevice ( AudioDevice . WIRED_HEADSET ) ; } else { setAudioDevice ( defaultAudioDevice ) ; } }
update list of possible audio devices and make new device selection .
