Troubleshooting guide
132
BlackBerry Java Development Environment Development Guide
}
}
_bluetoothConnection = null;
_din = null;
_dout = null;
}
// Open the serial port.
private void openPort() {
if (_bluetoothConnection != null) {
closePort();
}
new InputThread().start();
}
private class InputThread extends Thread {
public void run() {
try {
BluetoothSerialPortInfo[] info = BluetoothSerialPort.getSerialPortInfo();
if( info == null || info.length == 0 ) {
invokeAndWait( new Runnable() {
public void run() {
Dialog.alert( “No bluetooth serial ports available for connection.” );
closePort();
System.exit(1);
}
});
}
_bluetoothConnection = (StreamConnection)Connector.open( info[0].toString(),
Connector.READ_WRITE );
_din = _bluetoothConnection.openDataInputStream();
_dout = _bluetoothConnection.openDataOutputStream();
} catch(IOException e) {
invokeAndWait( new Runnable() {
public void run() {
Dialog.alert(“Unable to open serial port”);
closePort();
System.exit(1);
}
});
} catch( UnsupportedOperationException e ) {
invokeAndWait( new Runnable() {
public void run() {
Dialog.alert(“This handheld or simulator does not support bluetooth.”);
closePort();
System.exit(1);
}
});
}