j2me判断机器平台代码---参考了部分网上资料

private String getPlatform() { // Detecting NOKIA / SonyEricsson / Sun WTK emulator / Intent try { final String currentPlatform = System.getProperty("microedition.platform"); if (currentPlatform.indexOf("Nokia") != -1) { return KuixConstants.PLATFORM_NOKIA; } else if (currentPlatform.indexOf("SonyEricsson") != -1) { return KuixConstants.PLATFORM_SONY_ERICSSON; } else if (currentPlatform.indexOf("SunMicrosystems") != -1) { return KuixConstants.PLATFORM_SUN; } else if (currentPlatform.indexOf("intent") != -1) { return KuixConstants.PLATFORM_INTENT; } } catch (Throwable ex) { try { Class.forName("com.nokia.mid.ui.FullCanvas"); return KuixConstants.PLATFORM_NOKIA; } catch (Throwable ex2) { } } // Detecting SAMSUNG try { Class.forName("com.samsung.util.Vibration"); return KuixConstants.PLATFORM_SAMSUNG; } catch (Throwable ex) { } // Detecting MOTOROLA try { Class.forName("com.motorola.multimedia.Vibrator"); return KuixConstants.PLATFORM_MOTOROLA; } catch (Throwable ex) { try { Class.forName("com.motorola.graphics.j3d.Effect3D"); return KuixConstants.PLATFORM_MOTOROLA; } catch (Throwable ex2) { try { Class.forName("com.motorola.multimedia.Lighting"); return KuixConstants.PLATFORM_MOTOROLA; } catch (Throwable ex3) { try { Class.forName("com.motorola.multimedia.FunLight"); return KuixConstants.PLATFORM_MOTOROLA; } catch (Throwable ex4) { } } } } try { if (getKeyName(SOFT_KEY_LEFT_MOTOROLA).toUpperCase().indexOf(SOFT_WORD) > -1) { return KuixConstants.PLATFORM_MOTOROLA; } } catch (Throwable e) { try { if (getKeyName(SOFT_KEY_LEFT_MOTOROLA1).toUpperCase().indexOf(SOFT_WORD) > -1) { return KuixConstants.PLATFORM_MOTOROLA; } } catch (Throwable e1) { try { if (getKeyName(SOFT_KEY_LEFT_MOTOROLA2).toUpperCase().indexOf(SOFT_WORD) > -1) { return KuixConstants.PLATFORM_MOTOROLA; } } catch (Throwable e2) { } } } // Detecting SIEMENS try { Class.forName("com.siemens.mp.io.File"); return KuixConstants.PLATFORM_SIEMENS; } catch (Throwable ex) { } // Detecting LG try { Class.forName("mmpp.media.MediaPlayer"); return KuixConstants.PLATFORM_LG; } catch (Throwable ex) { try { Class.forName("mmpp.phone.Phone"); return KuixConstants.PLATFORM_LG; } catch (Throwable ex1) { try { Class.forName("mmpp.lang.MathFP"); return KuixConstants.PLATFORM_LG; } catch (Throwable ex2) { try { Class.forName("mmpp.media.BackLight"); return KuixConstants.PLATFORM_LG; } catch (Throwable ex3) { } } } } return KuixConstants.PLATFORM_NOT_DEFINED; }

你可能感兴趣的:(String,sun,Nokia,平台,j2me,Motorola)