J2ME 技术的学习与实践者

[导入]OpenBaseMovil 设备检测(2)


网站: JavaEye  作者: iwinyeah  链接:http://iwinyeah.javaeye.com/blog/169545  发表时间: 2008年03月09日

声明:本文系JavaEye网站发布的原创博客文章,未经作者书面许可,严禁任何网站转载本文,否则必将追究法律责任!

唉,有贴代码骗粮票的嫌疑呢,至少大家可以在这里看到各种设备的规格方法了.
    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

posted on 2008-03-09 18:55 iwinyeah 阅读(50) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: