2

I would to like to know if Is there any to check if I am running the application in a emulator or real phone? I want to change some configuration when I am testing in the netbeans/emulador and when it goes to real mobile phone change to another configuration such as server address. Is there any java me function to check it?

1
  • You must write your solution and accept it for helping future views of the question. It's important accept an answer
    – frayab
    Jan 26, 2012 at 12:49

2 Answers 2

3

You have to use this code.

String platform = System.getProperty("microedition.platform");
platform = platform.toUpperCase();
if ((platform.indexOf("J2ME") != -1) || (platform.equalsIgnoreCase("SunMicrosystems_wtk"))) {
 //EMULATOR
}else {
//Device
}

If you are using other emulator you can try doing System.out.println(platform) and see what print when yo are using on emulator

3
  • I afraid some unbranded phones returns j2me also. I was thinking to use System.getProperty("microedition.profiles") which returns me "MIDP-2.1 JAVAFX-1.1"
    – dextervip
    Jan 18, 2012 at 11:07
  • Really a use this: if (platform.indexOf("NOKIA") != -1) { //NOKIA; } else if (platform.indexOf("SAMSUNG") != -1) { //SAMSUNG; } else if (platform.indexOf("SONYERICSSON") != -1) { //SONY_ERICSSON; } else if (platform.indexOf("LG") != -1) { //LG; } else if ((platform.indexOf("BLACKBERRY") != -1) || (platform.indexOf("RIM") != -1)) { return BLACKBERRY; } else if ((platform.indexOf("J2ME") != -1) || (platform.equalsIgnoreCase("SunMicrosystems_wtk"))) { //EMULATOR; }
    – frayab
    Jan 18, 2012 at 11:27
  • with this you filter before that devices
    – frayab
    Jan 18, 2012 at 11:27
1

You can add a property in JAD, and just change that property when you build for real device

for example :

device-name: emulator

and you can read it in MIDlet using

getAppProperty("device-name");
1
  • 1
    i think this is not a real solution, you change this manually and he want a function for doing it at code
    – frayab
    Jan 18, 2012 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.