Skip to end of metadata
Go to start of metadata


Since build it is possible to swith to Bluetooth headset for audio input/output using Flashphoner.getAudioManager().setUseBluetoothSco() function call:

To switch to BT headset


To switch to other audio input/output device


The usage example. Please note that it is necessary to disable speakerphone and BT headset usage to switch to phone voice speaker or to wired headset.


        mAudioOutput = (LabelledSpinner) findViewById(;
        mAudioOutput.setOnItemChosenListener(new LabelledSpinner.OnItemChosenListener() {
            public void onItemChosen(View labelledSpinner, AdapterView<?> adapterView, View itemView, int position, long id) {
                String audioType = getResources().getStringArray(R.array.audio_output)[position];
                switch (audioType) {
                    case "speakerphone": Flashphoner.getAudioManager().setUseSpeakerPhone(true); break;
                    case "phone":
                    case "bluetooth": Flashphoner.getAudioManager().setUseBluetoothSco(true); break;

            public void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView) {


A simultaneous playback of media stream and a local media file to BT headphone

It is necessary to set the attribute AudioAttributes.USAGE_VOICE_COMMUNICATION and request audio focus for a mediaplayer in application to play simultaneously a media stream from server and a local media file from device to Bluetooth headphone, for example

                                                         * Audio focus example
                                                        MediaPlayer music = MediaPlayer.create(getBaseContext(), R.raw.sound1);
                                                               new AudioAttributes.Builder()
                                                        AudioManager.OnAudioFocusChangeListener audioFocusChangeListener = new AudioManager.OnAudioFocusChangeListener() {
                                                            public void onAudioFocusChange(int focusChange) {
                                                                Log.d("AudioFocus,", "onAudioFocusChange="+focusChange);
                                                                music.setVolume(1, 1);
                                                        // Request audio focus for playback
                                                        int requestResult = Flashphoner.getAudioManager().getAudioManager().requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
                                                        Log.d("AudioFocus,", "requestResult="+requestResult);
                                                        // Abandon audio focus when playback complete
                                                        music.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                                                            public void onCompletion(MediaPlayer mp) {
  • No labels