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
Walibi33
Posts: 70
Registered: ‎11-30-2009
My Device: Not Specified

How to handle post-4.6.0 methods on oldest BlackBerry devices ?

          Hi everybody,

 

     Here's my problem : I work on an appllication that is guaranted to work on every OS BlackBerry versions since JDE 4.2.1. But we would like to take advantage of some of the newest functionnalities provided by JDE 4.6.0 or older (ApplicationIndicator for instance) in case device using our applicationg is a pretty much decent one.

 

     How can I properly handle that ? Besides just adding a statement if (version.isOlfer("4.6.0")) {...} else {...} in my code...

 

          Thanks in advance.   

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

You cannot do this:

 

adding a statement if (version.isOlfer("4.6.0")) {...} else {...} in my code...

 

Because your compiled code will still reference the newer classes that do not exist on the older device.  You'll need to use the preprocessor to insure that the reference is not compiled into your object code.

 

Of course, now you have the issue that the "new" feature is not accessable t the "old" code - so you have to invent some reasonable facsimile of the new feature for the older OS level.

 

Sorry...there isn't any magic.

 

Please use plain text.
Developer
Walibi33
Posts: 70
Registered: ‎11-30-2009
My Device: Not Specified

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

I agree with you

 

But what I can do is compile my application code with JDE 4.6.0, upload the application on a BlackBerry device with 4.2.1 OS version for instance and there won't be any problem as long as I do not call specific code that are not handled by JDE 4.2.1...

I think this might be working right ? That's where the statement if (version.isOlfer("4.6.0")) {...} else {...} takes place. I was just wondering if there wasn't a better trick to do that.

 

The preprocessor thing can't resolve this issue either because it happens during compilation time... and we know our application is going to run on devices with OS version older and newer than the 4.6.0 one. We haven't thought about genrating different vesions regarding OS version of targeted device. I hope it won't be necessary.

 

What do you think ?

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

>> won't be any problem as long as I do not call specific code that are not handled by JDE 4.2.1...

 

This is not supported, regardless of wether it seems to work OK on one particular device or not.  You run the risk of "bricking" the customer's device (and take it from me, you don't want that hassle).

 

 

 

 

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

[ Edited ]

Just to say in different terms of what Rex said.

 

On normal Java (J2SE, Java SE) and pure J2ME (Nokia, Symbian, etc.) the class file is dynamically loaded, so you can do the if (version.isOlfer("4.6.0")) {...} else {...} code and it would work.

 

On BlackBerry it uses a different JVM and it doesn't use class files on the actual device, instead it uses COD. I expect you know that, when the COD file is loaded the JVM looks through and gets the indexes to the types, if the index does not exist then you get a error along the lines of "Def not found".

 

That is why the Jar file that is returned has a COD file in it, so the indexes can be referenced when rapc compiles it. That is why you can't simply check the version of the OS that is running it and have it skip over the code used in newer OSes, the JVM will look at it when the COD is loaded and say "I don't know what these classes are, throw an error."

 

If you happen to get it working anyway then you are either lucky or they changed the JVM.

 

The same thing happens on Android only in a per-Class manner instead of per-App.

 

Your workarounds are, as Rex said; Preprocessor, seperete app versions, or what some people do is make "component packs" for the different OSes so that it loads the appropriete COD at install time and at runtime.

---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.
Please use plain text.
Developer
Walibi33
Posts: 70
Registered: ‎11-30-2009
My Device: Not Specified

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

          Thanks you guys !

 

     Today the solution we're heading to is pretty much generating different .COD regarding OS versions we want to be able to deploy with. rcmaniac25 your last remark is pretty interesting though, it would be apparently possible to do this separation on runtime ? Do you know where I could find some documentation more specific about this particlular issue ?

 

 

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: How to handle post-4.6.0 methods on oldest BlackBerry devices ?

I don't believe you can sepereate the code at runtime but would have to do it at install time. Think of it like this:

 

User goes to website/App World/etc. from 4.5 device. Website/App World/etc. sees it's a 4.5 device and installs "BaseApp" and "UI4.5". Now at runtime BaseApp simply says something like Class.forName("BaseApp.UI.UIScreen").newInstance() and gets an Object, this gets converted to a Screen and displayed.

 

Now if you were on 4.6 (which has Border/Background classes) the CODs installed would be "BaseApp" and "UI4.6", everything else stays the same but it has a newer (at least in code) UI. UI4.7 would have touch support, UI5.0 etc.

 

So it would still be a compile time operation but it might be easier to adapt. I haven't put anything on App World yet but I know that this kind of stuff is supported.

---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.
Please use plain text.