Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 07:31, 23 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Retrieving name and address of local Bluetooth device in Java ME

From Wiki
Jump to: navigation, search

This code example demonstrates how to get the name and address of a local Bluetooth device by referencing the LocalDevice object.

Article Metadata
Code ExampleTested with
Devices(s): Nokia N85, Nokia 5800 XpressMusic, Nokia 2630, Nokia 6131, Nokia 701, Nokia Asha 305
Created: IlGolub (19 Feb 2009)
Last edited: hamishwillee (23 Jul 2013)

Source file:

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.LocalDevice;
* Executes the snippet.
* Implementation retrieves the local device bluetooth name and address and
* prints it out to log TextField.

private void executeSnippet() {
try {
//Object of LocalDevice type provides some
//functions of the Bluetooth manager.
//we get it through the static method getLocalDevice()
LocalDevice localDevice = LocalDevice.getLocalDevice();
//through the getFriendlyName() method we can get the
//name of the local bluetooth device.
//The Bluetooth specification calls this name the
//"Bluetooth device name" or the "user-friendly name".
String localDeviceName = localDevice.getFriendlyName();
printString("Local device name: " + localDeviceName);
//through the getBluetoothAddress() method we can get the
//adress of the local bluetooth device
String localDeviceAdress = localDevice.getBluetoothAddress();
printString("Local device adress: " + localDeviceAdress);
} catch (BluetoothStateException ex) {


After starting the MIDlet, run the 'Execute snippet' command to display the name and address of the local Bluetooth device.

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