Bluetooth connection

How do I know if a BluetoothSocket is connected to an endpoint? How can I determine if a connector is disconnected by an endpoint?

thank

+3
source share
1 answer

In my applications, I track I / O errors. If successful read()takes place, then I reset the counters. If the error counts rise high enough (usually 4-5 is a good number), I think the connection is dead, and continue to tear it down and rebuild it.

The SDK says the intention is to change the state, but I don’t understand whether this applies to the specific connection or the bluetooth adapter itself here :

, ACTION_STATE_CHANGED , , Bluetooth . EXTRA_STATE EXTRA_PREVIOUS_STATE, Bluetooth, . STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF STATE_OFF. , Bluetooth .

+2

Source: https://habr.com/ru/post/1752423/


All Articles