50% OFF!!!

Monday, May 17, 2010

J2ME | determine BlackBerry device (OS)

Here is a code for determine whether a J2ME application is running over Blackberry device.

The idea is to check for a class that exists only in Blackberry platform and not on J2ME MIDP Operation system.
here I choose to determine using "net.rim.blackberry.api.browser.Browser" which exists only in Blackberry OS (NOT in other OSs).

The code using Class.forClass method (link) which returns the Class object associated with the class or interface with the given string name. if the class exists (so we in Blackberry) the method return an object, otherwise throws an exception.

here is a simple code:
static public boolean isBlackberryPlatform()
            return true;
        catch (Exception ex)
            return false;

enjoy, and post replies...

No comments:

Post a Comment