How to play audio through Bluetooth speaker even when headset is plugged in?

前端 未结 5 603
夕颜
夕颜 2021-02-06 00:53

I have my phone connected to a Bluetooth speaker and the headphones plugged in. Now I\'d like to play audio through the Bluetooth speaker. When I set the audio stream to A

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 01:17

    You need to instantiate a new object of class MediaPlayer and use the following method on it

     amediaplayer.setAudioStreamType(AudioManager.STREAM_RING)
    

    Do not forget to check authorization to use bluetooth, you are unable to send anything to speaker via bluetooth without user privilege as you know.

提交回复
热议问题