If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
jacobtabak
Posts: 34
Registered: ‎03-14-2010
My Device: N/A
My Carrier: Fledge
Accepted Solution

Targeting different OS versions with the same code

Hello again,

 

I'm looking to use certain features of the 5.0 OS such as the transition API.  Is there any way to have one codebase that will compile in different versions of the JDE but exclude certain blocks of code if the OS doesn't meet the requirements?

 

For example, the transitions would appear on a 5.0 OS device but not on a 4.5 OS device.

 

Ideally, I am looking for a solution that would integrate directly with Eclipse and debug without any additional steps in both versions of the OS.

Please use plain text.
Developer
lcamobile
Posts: 76
Registered: ‎03-15-2010
My Device: 9800, 9630
My Carrier: Rogers

Re: Targeting different OS versions with the same code

Try doing some research on "preprocessor directives", you can use this to do what you need.

 

Basically, you wrap the 5.0 OS code in directives such as :

 

//#ifdef VER_5
        System.out.println("this compiles for 5.0");
//#else
        System.out.println("this compiles for non 5.0");
//#endif   

 

Then you activate or deactivate the directives in the compiler to build COD versions for each platform.

 

Jason

www.lcamobile.com

 

 

 

Please use plain text.
Contributor
jacobtabak
Posts: 34
Registered: ‎03-14-2010
My Device: N/A
My Carrier: Fledge

Re: Targeting different OS versions with the same code

Thanks, that's exactly what I was looking for. I appreciate your help!

Please use plain text.