I am developing an application for Android. This app should communicate with a Bluetooth (BT) device (sending some bytes). I have a problem with debugging/running this app on my device (Samsung Galaxy mini). When I create a BT socket and stop debugging, phone freeze and I have to restart it by getting out the battery. In case of running this app (from Eclipse) everything is OK, but when I try to run it again, phone freeze and app is not installed. If I try to unninstall this app manualy before second run, phone freeze again. Here is a problematic code:
private final BluetoothDevice mmDevice;
private UUID uuid;
public ConnectionThread(BluetoothDevice device) {
Log.d(TAG, "create ConnectionThread");
uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothSocket tmp = null;
mmDevice = device;
try {
tmp = mmDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) { }
mmSocket = tmp;
socketConnected = true;
}
This is a constructor of thread. When I comment the line
tmp = mmDevice.createRfcommSocketToServiceRecord(uuid);
the phone doesn´t freeze so problem is with creating socket (not connecting). Restarting phone after each debugging or running is pretty annoying and I have to do a lot of work yet.
If I run this app from a phone (disconnected from Eclipse), it works without any problems. Any ideas where could be a problem or how to fix it? Thank you.