Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
uniquehussam
Posts: 28
Registered: ‎03-15-2012
My Carrier: Du-UAE

Bluetooth Search issue :)))

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."));
}

}


}

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Carrier: Wind

Re: Bluetooth Search issue :)))

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.

Please use plain text.
Developer
pbrebs
Posts: 40
Registered: ‎09-08-2011
My Carrier: AIS

Re: Bluetooth Search issue :)))

You refer to "devList[devcount]" without having assigned a value to that element.

Please use plain text.
Contributor
uniquehussam
Posts: 28
Registered: ‎03-15-2012
My Carrier: Du-UAE

Re: Bluetooth Search issue :)))

Dear vingilot,

I'd like to see what paired devices are available in my range
and then put them in a list using their names @ .getServiceName()
so that later in my app i can choose a device to communicate with

Dear pbrebs,

I did ..
devList[count] = _portInfo[count].getServiceName();
where
devcount and count are integers with the same value
see the loop
I dunno if there is an issue with that :smileyhappy:)))


Thanks all for the interaction..
hope to get a solution soon
^_^
Please use plain text.
Contributor
uniquehussam
Posts: 28
Registered: ‎03-15-2012
My Carrier: Du-UAE

Re: Bluetooth Search issue :)))

Dear all,

All I want to do is exactly the same as when you go to
Bluetooth Connections>> Add New Device >> Search
and then a list of all devices is available
^_^

If anyone has that bit of code
please please please share it with us

Thanks,
^____^
Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

Re: Bluetooth Search issue :)))

Have a look at the BluetoothJSR82Demo included with the BlackBerry Java SDK for an example that implements device discovery.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Contributor
uniquehussam
Posts: 28
Registered: ‎03-15-2012
My Carrier: Du-UAE

Re: Bluetooth Search issue :)))

Well i am finding an issue in actually getting what the code is supposed to be doing..

i read the code.. and i can see menu items in some samples and other components and stuff
however, when i load them on my device they miss many of these!

ex. the JSR82 has a dialog to choose the mode..
client/server then the app is closed !!

I have a 3 different devices.. 2 of which are brand new
tourch and curve-touch
Please use plain text.