I have a strange issue with bluetooth socket. If I create socket and later close application, android device freeze with very hight CPU load.
Here my sample code:
<
Did the socket get successfully created before calling the Close() method ? I would try initializing the socket to null before the call to createRfcommSocketToServiceRecord(UUID) The Bluetooth Chat example does this .. here is a snippet .
public ConnectThread(BluetoothDevice device) {
mmDevice = device;
BluetoothSocket tmp = null;
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
}
mmSocket = tmp;
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of connect socket failed", e);
}
}