OpenBaseMovil 装置检测(2)
OpenBaseMovil 设备检测(2)
唉,有贴代码骗粮票的嫌疑呢,至少大家可以在这里看到各种设备的规格方法了.
唉,有贴代码骗粮票的嫌疑呢,至少大家可以在这里看到各种设备的规格方法了.
public static boolean isBlackBerry() { return checkPlatform( "RIM" ); } public static boolean checkPlatform( final String key ) { final String platform = System.getProperty( "microedition.platform" ); return platform != null && platform.toUpperCase().indexOf( key.toUpperCase() ) > -1; } public static boolean checkUserAgent( final String key ) { final String userAgent = Application.getManager().getProperty( "user-agent" ); return userAgent != null && userAgent.toUpperCase().indexOf( key.toUpperCase() ) > -1; } public static boolean checkPlatform( final String[] keys ) { final int length = keys.length; for( int i = 0; i < length; i++ ) { if( checkPlatform( keys[i] ) ) { return true; } } return false; } public static boolean isNokia() { return checkPlatform( "Nokia" ); } public static boolean isEmulator() { return checkPlatform( new String[] { "j2me", "SunMicrosystems_wtk" } ); } public static boolean isSonyEricsson() { return checkPlatform( "SonyEricsson" ); } public static boolean isSonyEricssonJP7() { return isSonyEricsson() && checkPlatform( JP7 ); } public static boolean isSymbian() { return checkUserAgent( "SymbianOS" ); } public static boolean isSeries60() { return checkUserAgent( "Series60" ); } public static boolean isSeries60_2nd() { return checkUserAgent( "Series60/2" ); } public static boolean isSeries60_3rd() { return checkUserAgent( "Series60/3" ); }