This discussion is archived
2 Replies Latest reply: Apr 17, 2012 9:07 AM by DarrylBurke RSS

java me bluetooth device id

931155 Newbie
Currently Being Moderated
Hi,

I am developing an application which require to get unique id of mobile phone for that i am taking Bluetooth id... I searched some codes on google, & tried it on my samsung & micromax mobile phone, but it shows unsupported midlet.

the code is as follows



import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.bluetooth.*;

public class UNID extends MIDlet implements CommandListener {

private Display display;
private Command exit;
LocalDevice local;
Alert a;

public UNID() {

display = Display.getDisplay(this);
exit = new Command("Exit",Command.EXIT, 0);
a = new Alert("Local Device");
a.addCommand(exit);
a.setCommandListener(this);

}

public void startApp() {

try {

// Retrieve the local Bluetooth device object
local = LocalDevice.getLocalDevice();

// Retrieve the Bluetooth address of the local device
String address = local.getBluetoothAddress();

// Retrieve the name of the local Bluetooth device
String name = local.getFriendlyName();
System.out.println(address + name);
a.setString("Address is"+address+" Name is "+name);
display.setCurrent(a);

} catch(Exception e) {
e.printStackTrace();
}
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c,Displayable d) {

if(c == exit) {
notifyDestroyed();
destroyApp(true);
}

}
}

PLease help me ......
:)
  • 1. Re: java me bluetooth device id
    865727 Newbie
    Currently Being Moderated
    Are you sure the phone supports the Java ME Bluetooth API? What do you think about using IMEI instead? If so, try bellow keys:
            System.getProperty("phone.imei");
            System.getProperty("com.nokia.IMEI");
            System.getProperty("com.nokia.mid.imei");
            System.getProperty("com.sonyericsson.imei");
            System.getProperty("IMEI");
            System.getProperty("com.motorola.IMEI");
            System.getProperty("com.samsung.imei");
            System.getProperty("com.siemens.imei");
            System.getProperty("imei");
    Code obtained from http://stackoverflow.com/questions/9861368/knowing-the-network-operator-name-in-j2me

    Edited by: Telmo Pimentel Mota on 17/04/2012 11:31
  • 2. Re: java me bluetooth device id
    DarrylBurke Guru Moderator
    Currently Being Moderated
    Announcements at the top of the forum listing are meant to be read. Clearly, you didn't bother.

    db

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points