06-18-2012 05:49 AM - edited 06-18-2012 06:14 AM
Hello Community,
I am trying to connect BlackBerry Bold 9900 to a Bluetooth device having SPP. But when I try to open a connection, it fails with an exception (java.io.IOException: Unable to connect.) I cannot understand why its not getting connected.
I am using the BlackBerry JDE Eclipse plugin with platform version 4.5.
Posting the code here, please someone have a look at it;
public final class ReaderScreen extends MainScreen {
private BluetoothSerialPortInfo[] serialPortInfo;
private StreamConnection bluetoothConnection;
private DataInputStream inputStream;
private String contents;
private LabelField label;
/**
* Creates a new ReaderScreen object
*/
public ReaderScreen() {
setTitle("Reader");
label = new LabelField("Started");
add(label);
serialPortInfo = BluetoothSerialPort.getSerialPortInfo();
if (serialPortInfo == null) {
appendLabel("info is null.");
} else {
appendLabel("info is not null.");
}
appendLabel("Going to open connection...");
appendLabel("Connecting to device " + serialPortInfo[0].toString());
try {
appendLabel("Inside the first thread.");
bluetoothConnection = (StreamConnection) Connector.open(
serialPortInfo[0].toString(), Connector.READ);
if (bluetoothConnection == null) {
appendLabel("connection is null.");
} else {
appendLabel("connection is not null.");
}
} catch (IOException e) {
e.printStackTrace();
appendLabel("Exception in constructor");
appendLabel(e.toString());
} catch (Exception e) {
e.printStackTrace();
appendLabel("Gen Exception in constructor");
appendLabel(e.toString());
}
appendLabel("Starting thread...");
UiApplication.getUiApplication().invokeLater(new ReaderThread());
}
06-18-2012 05:53 AM
06-18-2012 05:55 AM
06-18-2012 05:58 AM
06-18-2012 06:01 AM
06-18-2012 06:05 AM
06-18-2012 06:52 AM
06-18-2012 06:58 AM