不同平台的密钥代码

时间:2012-06-14 04:18:26

标签: java-me midp lcdui

我正在为移动设备开发j2me应用程序。在我的应用程序中,我必须采用设备的平台,并根据我必须得到密钥代码。

我参考了以下链接:http://www.iteye.com/topic/179073(请参阅下面的平台检测代码片段。)

现在我的问题是我必须采用Micromax和熔岩手机的平台,但它在该链接中不可用。我也在网上搜索,但我找不到正确的链接。

/** 
 * Returns mobile phone platform 
 * 
 * @return name mobile phone platform 
 */  
private String getPlatform() {  
    // detecting NOKIA or SonyEricsson  
    try {  
        final String currentPlatform = System.getProperty("microedition.platform");  
        if (currentPlatform.indexOf("Nokia") != -1) {  
            return PLATFORM_NOKIA;  
        } else if (currentPlatform.indexOf("SonyEricsson") != -1) {  
            return PLATFORM_SONY_ERICSSON;  
        }  
    } catch (Throwable ex) {  
    }  
    // detecting SAMSUNG  
    try {  
        Class.forName("com.samsung.util.Vibration");  
        return PLATFORM_SAMSUNG;  
    } catch (Throwable ex) {  
    }  
    // detecting MOTOROLA  
    try {  
        Class.forName("com.motorola.multimedia.Vibrator");  
        return PLATFORM_MOTOROLA;  
    } catch (Throwable ex) {  
        try {  
            Class.forName("com.motorola.graphics.j3d.Effect3D");  
            return PLATFORM_MOTOROLA;  
        } catch (Throwable ex2) {  
            try {  
                Class.forName("com.motorola.multimedia.Lighting");  
                return PLATFORM_MOTOROLA;  
            } catch (Throwable ex3) {  
                try {  
                    Class.forName("com.motorola.multimedia.FunLight");  
                    return PLATFORM_MOTOROLA;  
                } catch (Throwable ex4) {  
                }  
            }  
        }  
    }  
    try {  
        if (adaptorCanvas.getKeyName(SOFT_KEY_LEFT_MOTOROLA).toUpperCase().indexOf(SOFT_WORD) > -1) {  
            return PLATFORM_MOTOROLA;  
        }  
    } catch (Throwable e) {  
        try {  
            if (adaptorCanvas.getKeyName(SOFT_KEY_LEFT_MOTOROLA1).toUpperCase().indexOf(SOFT_WORD) > -1) {  
                return PLATFORM_MOTOROLA;  
            }  
        } catch (Throwable e1) {  
            try {  
                if (adaptorCanvas.getKeyName(SOFT_KEY_LEFT_MOTOROLA2).toUpperCase().indexOf(SOFT_WORD) > -1) {  
                    return PLATFORM_MOTOROLA;  
                }  
            } catch (Throwable e2) {  
            }  
        }  
    }  
    // detecting SIEMENS  
    try {  
        Class.forName("com.siemens.mp.io.File");  
        return PLATFORM_SIEMENS;  
    } catch (Throwable ex) {  
    }  
    // detecting LG  
    try {  
        Class.forName("mmpp.media.MediaPlayer");  
        return PLATFORM_LG;  
    } catch (Throwable ex) {  
        try {  
            Class.forName("mmpp.phone.Phone");  
            return PLATFORM_LG;  
        } catch (Throwable ex1) {  
            try {  
                Class.forName("mmpp.lang.MathFP");  
                return PLATFORM_LG;  
            } catch (Throwable ex2) {  
                try {  
                    Class.forName("mmpp.media.BackLight");  
                    return PLATFORM_LG;  
                } catch (Throwable ex3) {  
                }  
            }  
        }  
    }  
    return PLATFORM_NOT_DEFINED;  
}  

0 个答案:

没有答案