Friday 20 February 2009

Finding out the different phone platforms

public static final String J2ME_PLATFORM = (System.getProperty("microedition.platform") != null ? System.getProperty("microedition.platform").toLowerCase() : "");

//Method to check if the phone is using Sony Ericsson platform
public static final boolean IS_SONYERICSSON = J2ME_PLATFORM.startsWith("sonyericsson");

//Method to check if the phone is using Nokia platform
public static final boolean IS_NOKIA = J2ME_PLATFORM.indexOf("nokia") != -1;

//Method to check if the phone is using Samsung platform

private static boolean isSamsung() {
try {
Class.forName("com.samsung.util.AudioClip");
return true;
} catch (Throwable t0) {
try{
Class.forName("com.samsung.util.Vibration");
return true;
}catch(Throwable t1){}
}
return false;
}

//Method to check if the phone is using LG platform
private static boolean isLG() {
try {
Class.forName("mmpp.media.MediaPlayer");
return true;
} catch (Throwable ex) {
try {
Class.forName("mmpp.phone.Phone");
return true;
} catch (Throwable ex1) {
try {
Class.forName("mmpp.lang.MathFP");
return true;
} catch (Throwable ex2) {
try {
Class.forName("mmpp.media.BackLight");
return true;
} catch (Throwable ex3) {
}
}
}
}
return false;
}

No comments: