Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

detect bluetooth headphones android programmatically

fun isBluetoothHeadsetConnected(): Boolean {
    val mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
    return (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled
        && mBluetoothAdapter.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothHeadset.STATE_CONNECTED)
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #detect #bluetooth #headphones #android #programmatically
ADD COMMENT
Topic
Name
9+5 =