Reputation: 2290
Maybe I miss something, but How can I change the timeout of BluetoothSocket.connect() ?
Thanks you
Anthony
Upvotes: 0
Views: 1089
Reputation: 857
You can't change timeout of BluetoothSocket.connect(). As documentation:
This method will block until a connection is made or the connection fails. If this method returns without an exception then this socket is now connected.
A workaround.
Ex: timeout 5s. Using CountDownTimer to check if connect is complete(success or fail). After 5s, if connection is incomplete then use BluetoothSocket.close() to cancel.
As BluetoothSocket documentation:
close() can be used to abort this call from another thread.
Upvotes: 3