[導入]OpenBaseMovil 設備檢測(2)
網(wǎng)站: JavaEye 作者: iwinyeah 鏈接:http://iwinyeah.javaeye.com/blog/169545 發(fā)表時間: 2008年03月09日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書面許可,嚴禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責任!
唉,有貼代碼騙糧票的嫌疑呢,至少大家可以在這里看到各種設備的規(guī)格方法了.
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" ); }
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來源:http://iwinyeah.javaeye.com/blog/169545