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

Native Development

Reply
Developer
Suns33k3r
Posts: 26
Registered: ‎07-22-2012
My Device: Z10
My Carrier: Telstra
Accepted Solution

Extract version number from bar-descriptor.xml programatically

Is there a way to extract a version number and other information from bar-descriptor.xml file similar to how it's done in Android world via getPackageInfo() in PackageManager?

 

That'd be a handy way to play around those values in your code.

 

Thanks

Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Extract version number from bar-descriptor.xml programatically

[ Edited ]

There are various platform apis that you can use such as the PackageInfo,

 

http://developer.blackberry.com/cascades/reference/bb__packageinfo.html

 

or ApplicationInfo,

 

http://developer.blackberry.com/cascades/reference/bb__applicationinfo.html

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Extract version number from bar-descriptor.xml programatically

Suns33k3r, since you asked in the Native SDK forum, perhaps you don't have access to Cascades APIs.

In that case you may want to just read from the app/META-INF/MANIFEST.MF file and parse it to find the "Package-Version" field.

I believe that's the real location for the version number used by the system. The bar-descriptor.xml file is used during packaging, but the version is extracted from there, combined with the buildId (if you didn't include all four parts) and then stored in the MANIFEST.MF file with other stuff.

There may be another place you can get it through the Native SDK using a proper API but I'm not aware of that.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
sorout2009
Posts: 104
Registered: ‎08-23-2012
My Device: Blackberry Z10
My Carrier: TATA DOCOMO

Re: Extract version number from bar-descriptor.xml programatically

You can use ApplicationInfo class to find out application version like this

 

ApplicationInfo app_info;

app_info.version();

 

Also you can use

 

PackageInfo pack_info;

pack_info.version();

 

This will return version in 0.0.0.0 format. The first three portion contains package version and last one is the package build id.

Dharmender Singh
Please use plain text.