I can only find how to show paired bluetooth devices and not the current connected bluetooth devices. This is the code to show paired:
val blueToothManager=applicationContext.getSystemService(BLUETOOTH_SERVICE) as BluetoothManager
val bluetoothAdapter=blueToothManager.adapter
var pairedDevices = bluetoothAdapter.bondedDevices
var data:StringBuffer = StringBuffer()
for(device: BluetoothDevice in pairedDevices)
{
data.append(device.name + " ")
}
if(data.isEmpty())
{
bluetoothText.text = "0 Devices Connected"
val leftDrawable: Drawable? = getDrawable(R.drawable.ic_bluetooth_disabled)
val drawables: Array<Drawable> = bluetoothText.getCompoundDrawables()
bluetoothText.setCompoundDrawablesWithIntrinsicBounds(
leftDrawable, drawables[1],
drawables[2], drawables[3]
)
}
else
{
bluetoothText.text = data
val leftDrawable: Drawable? = getDrawable(R.drawable.ic_bluetooth_connected)
val drawables: Array<Drawable> = bluetoothText.getCompoundDrawables()
bluetoothText.setCompoundDrawablesWithIntrinsicBounds(
leftDrawable, drawables[1],
drawables[2], drawables[3]
)
}
Anybody know how to show current connected bluetooth devices and not paired devices? Thanks