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
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
Accepted Solution

Question on upward compatability

I have read that code is upward compatible meaning that an app written with the 4.5 api should run on later models of the phone.  On the other hand I have also seen code like this;

 

//#ifdef ABOVE_4_6
               phoneNumber = callInfo.getPhoneNumber();
//#else
               phoneNumber = callInfo.getDisplayPhoneNumber();  
//#endif

 

Indicating that different code is needed for different API:s. Could someone elaborate this a bit? Currently

I have  the same source for 4.5, 4.6, 4.7, 5 and 6  but at various places I have precompiler statements like the one above.

For world wide distribution it  is a bit  cumbersome to have to 5 different executables.  Or is it possible to code so that the correct API to use is decided at runtime instead of at  compile time

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Question on upward compatability

It's not possible to pick the proper API at runtime (at least not now). If you try to install a COD with APIs from 6.0 on a device running 4.5, it would either not install or crash on starting up. The "upwards compatability" that is talked about is to mean that if you made an app for 4.2.1, it will work on 6.1. Preprocessor is the best way to go since, at least for Eclipse, when you switch API versions, it automatically switches the preprocessor for that API version.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700

Re: Question on upward compatability

Thanks rcmaniac25

 

I was not fully aware of  the upwards compatability so I had precompiler statements at  appropiate places to use the most recent api call when coding from 4.5 to 6 I realize now that that is not really needed since the 4.5 code works fine on all of these OS:es  (tested). So the problem sort of "went away" at least for the current relesae of the app. There are 2 new releases under way and hopefully it will stay that way.

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-