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
titakalpesh
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone
Accepted Solution

Get application version in code

Him, I want to show the version of my application in my application so is there any way by using that we can get the version of application that we set in project property.

Please use plain text.
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: Get application version in code

Hi do u want the version of the your code to be displayed after the cod files have been singed in the mobile??

Please use plain text.
Developer
titakalpesh
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: Get application version in code

I want to write a code in such a way that at run time it get the application version I set at the time of generating of code file in application property.

Please use plain text.
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: Get application version in code

Hi i shall tel what i know...well u can set the version before signing the code files into the mobile in ur projects  .alx files.

 

 

Please use plain text.
Developer
titakalpesh
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: Get application version in code

ya I set the version before I sign the application through JDE that reflect in .alx file and .jad file so would you tell me how to that version.

Please use plain text.
Developer
simon_hain
Posts: 16,136
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Get application version in code

this should help:

CodeModuleManager.getModuleVersion(CodeModuleManager.getModuleHandleForObject(this))

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
sachin_r
Posts: 81
Registered: ‎01-28-2009
My Device: Not Specified

Re: Get application version in code

Try this

 

ApplicationDescriptor.currentApplicationDescriptor().getVersion();

Don't forget to mark your post as solved if you got answer. And give kudos.
Please use plain text.
Developer
Pascal_Bourque
Posts: 149
Registered: ‎03-09-2009
My Device: Not Specified

Re: Get application version in code

sachin_r is right. It is the best way to get the current version of the appliaction.

 

ApplicationDescriptor.currentApplicationDescriptor().getVersion();

Pascal Bourque, Analyste-Programmeur : "je pense donc je programme"
Really want to thank a user? Click the Kudos! badge on right side of the message. When you do so, you are offering a thumbs up for good content and a pat on the back to its author.
Accepted Solutions is a way for you to choose the reply that best answers a thread that you've started. To mark a message as a solution: Click the Solution? icon on the reply.
Please use plain text.
Contributor
vipintomer
Posts: 41
Registered: ‎05-03-2012
My Device: 9800 torch

Re: Get application version in code

This code will return only 0.0 so you need to call the below function for getting jad file version.
public static synchronized String getAppVersion() {
    ApplicationDescriptor descriptor = ApplicationDescriptor.currentApplicationDescriptor();
    String version = descriptor.getVersion(); //read from the alx files
    if(version == null || version.trim().equals("0.0")) { //read value from jad file
     CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
if (moduleName == null || allGroups == null) {
return "1.0 (sim)"; // be default, for simulator
}
for (int i = 0; i < allGroups.length; i++) {
if (allGroups[i] != null && allGroups[i].containsModule(moduleName)) {
version = allGroups[i].getProperty("MIDlet-Version");
if(version != null)
return version;
}
}
return "1.0 (dev)";
    }
    return version;
}
Please use plain text.