How to programmatically tell if a Bluetooth device is connected?

前端 未结 7 1573
耶瑟儿~
耶瑟儿~ 2020-11-22 13:14

I understand how to get a list of paired devices but how can I tell if they are connected?

It must be possible since I see them listed in my phone\'s Bluetooth devi

7条回答
  •  一向
    一向 (楼主)
    2020-11-22 13:27

    BluetoothAdapter.getDefaultAdapter().isEnabled -> returns true when bluetooth is open

    val audioManager = this.getSystemService(Context.AUDIO_SERVICE) as AudioManager

    audioManager.isBluetoothScoOn -> returns true when device connected

提交回复
热议问题