S
Schütz12
Neues Mitglied
- 0
Hallo Leute
Ich versuche nun schon lange eine Verbindung mit einem Bluetooth Gerät hinzubekommen. Leider scheitert es bei mir bei dieser Funktion:
bluetoothSocket.connect();
Bei dieser Zeile bricht das Programm zwar nicht ab aber es macht den ProgrammCode nicht weiter.
Hier das Programm:
btDevice = mbluetoothdevice.get(i);
BluetoothSocket bluetoothSocket=null;
try {
bluetoothSocket = btDevice.createRfcommSocketToServiceRecord(
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
} catch (IOException e) {
// handle exception
}
bluetoothAdapter.cancelDiscovery();
try {
// Connect the device through the socket. This will block
// until it succeeds or throws an exception
bluetoothSocket.connect();
begin.setText("Connect with "+btDevice);
} catch (IOException connectException) {
// Unable to connect; close the socket and get out
try {
bluetoothSocket.close();
} catch (IOException closeException) {
// handle exception
}
}
Was könnte hier der Fehler sein?
Danke für Antworten
Der ursprüngliche Beitrag von 16:55 Uhr wurde um 16:55 Uhr ergänzt:
Ich bekomme halt keine Verbindung zusammen und es muss an den letzten try-catch Block liegen
Ich versuche nun schon lange eine Verbindung mit einem Bluetooth Gerät hinzubekommen. Leider scheitert es bei mir bei dieser Funktion:
bluetoothSocket.connect();
Bei dieser Zeile bricht das Programm zwar nicht ab aber es macht den ProgrammCode nicht weiter.
Hier das Programm:
btDevice = mbluetoothdevice.get(i);
BluetoothSocket bluetoothSocket=null;
try {
bluetoothSocket = btDevice.createRfcommSocketToServiceRecord(
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
} catch (IOException e) {
// handle exception
}
bluetoothAdapter.cancelDiscovery();
try {
// Connect the device through the socket. This will block
// until it succeeds or throws an exception
bluetoothSocket.connect();
begin.setText("Connect with "+btDevice);
} catch (IOException connectException) {
// Unable to connect; close the socket and get out
try {
bluetoothSocket.close();
} catch (IOException closeException) {
// handle exception
}
}
Was könnte hier der Fehler sein?
Danke für Antworten
Der ursprüngliche Beitrag von 16:55 Uhr wurde um 16:55 Uhr ergänzt:
Ich bekomme halt keine Verbindung zusammen und es muss an den letzten try-catch Block liegen