×
Namespaces

Variants
Actions

Archived:Retrieving the Bluetooth friendly name of a remote device using Java ME (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

This article explains how to get the Bluetooth friendly name of a remote device using Java ME on S40 and Series 40 2nd Edition.

Article Metadata
Code ExampleTested with
Devices(s): All
CompatibilityArticle
Created: User:Technical writer 2 (19 Oct 2006)
Last edited: hamishwillee (23 Jul 2013)

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.

This page was last modified on 23 July 2013, at 07:38.
43 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×