Categories: Technical Solution | Java ME | Bluetooth API (JSR-82) | Series 40 2nd Edition | Series 40 3rd Edition
This page was last modified 07:29, 11 October 2007.
TSJ000444 - Retrieving the Bluetooth friendly name of a remote device
From Forum Nokia Wiki
Subject: | Retrieving the Bluetooth friendly name of a remote device | TSJ000444 | |
|
| Platform(s): | Device(s), SW version(s): | |
| Series 40 2nd Edition Series 40 3rd Edition | All | ||
Category: | Java | ||
Subcategory: | Bluetooth API | ||
Description: | In order to retrieve the friendly name of a remote device, an application must call the RemoteDevice.getFriendlyName() method, passing either "true" or "false". Using "false", the implementation will first look for a friendly name for that particular device in its cache. If one cannot be found, the remote device will be contacted and requested a friendly name. Using "true" as the parameter, no cache search will be performed, and the remote device will always be contacted for a friendly name. In Series 40 2nd Edition devices, calling RemoteDevice.getFriendlyName() during device discovery or service search will throw a java.io.IOException every time. It is not possible to retrieve the friendly name. To test this issue: - Download the Devicediscovery.zip application. - Install it to your Series 40 2nd Edition device using OTA download or PC Suite. - Run the DeviceDiscovery application. Choose the "Disc60" command option, and the application will try to retrieve friendly names for the devices while the device discovery process is still running. This will throw java.io.IOException in all cases. A workaround for this problem is to do as follows: - First, retrieve all RemoteDevice objects and place them in a holder, such as a Vector. - When DiscoveryListener.inquiryCompleted() is called by the framework, the application can then traverse the Vector and call getFriendlyName() for each device in order to retrieve its friendly name and display it. The "Disc40" command option of the DeviceDiscovery application uses this workaround to provide a viable way of retrieving the friendly name of the discovered devices. Note that there is also another workaround demonstrated in the DiscoverConnect example that is part of the Games Over Bluetooth: Recommendations To Game Developers document. The remote devices themselves take care of informing their friendly names to the device running device/service discovery. As this functionality has to be written into the application logic, it means in practice that you need to run the same application in both ends. You cannot find out the friendly names of devices not running the MIDlet. However, this might be a useful approach in multiplayer games. Solution: In Series 40 3rd Edition and S60 platform (all editions), calling RemoteDevice.getFriendlyName() during discovery or search returns the correct result. Note, however, that this call may also throw java.io.IOException in these platforms, but in this case throwing the exception is proper behavior because it means that the remote device could not be contacted. | ||
Creation date: | October 19, 2006 | ||
Last modified: | - | ||
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a known bt device to the bt registry | bfamler | Symbian Networking & Messaging | 0 | 2007-02-13 10:53 |
| Interface or something else ? | Tiger79 | Mobile Java General | 0 | 2007-05-11 08:58 |
| Bluetooth, 3650, and pcsuite | getmoe | Bluetooth Technology | 5 | 2003-04-29 03:27 |
| SMS over Bluetooth | BalakrishM | Bluetooth Technology | 3 | 2005-03-17 12:54 |
| Determine if a phone has JAVA or not | jeswt | Mobile Java General | 4 | 2007-10-06 01:18 |

