1

我正在为移动设备开发一个 j2me 应用程序。在我的应用程序中,我必须使用设备的平台,并在此基础上获取密钥代码。

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

现在我的问题是我必须使用 Micromax 和 lava 手机的平台,但该链接中没有。我也在网上搜索过,但我无法获得正确的链接。

/** 
 * 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;  
}  
4

0 回答 0