04-19-2012 07:15 PM
Dear developers,
I'm trying to search for devices within my app
This code gives me "java.lang.nullpointerexception" error
Pls help ^^
public final class MyScreen extends MainScreen
{
public static BluetoothSerialPortInfo[] _portInfo;
public static String devList [] ;
public static int devcount ;
public MyScreen()
{
if (BluetoothSerialPort.isSupported())
{
_portInfo = BluetoothSerialPort.getSerialPortInfo();
int numServices = _portInfo.length;
for (int count = numServices - 1; count >= 0; --count)
{
devList[count] = _portInfo[count].getServiceName();
devcount++;
}
add(new LabelField(devList [devcount],LabelField.FIELD_HCENTER ));
}
else
{
add(new LabelField("Bluetooth is not supported on this device."));
}
}
}
04-19-2012 08:01 PM
Hey! Very interested, are you trying to identify connected devices? As I have been told this is not possible. I'd like to wait for a more experienced developer's input. If we cannot determine connected devices, I have considered using the discovery listener to determine devices in range, as I know this can be done and I believe I might be able to work this as an alternative. Hope we both get clarification on this.
04-19-2012 08:59 PM
You refer to "devList[devcount]" without having assigned a value to that element.
04-20-2012 06:47 AM
04-20-2012 06:59 AM
04-23-2012 10:22 PM
Have a look at the BluetoothJSR82Demo included with the BlackBerry Java SDK for an example that implements device discovery.
04-25-2012 01:03 PM