Quote:
Originally Posted by robinShazam How do i get the version of the device software? For example, i am after a string or byte[] that would report "4.2.0" or "4.2.1", etc for the device. I can get the platform version, e.g. 2.6.0.40, but that is not what i am after. |
I do it this way, which works with OS < 4.3 also. I get the version of the ribbon application, and trim off the fourth minor version number, if any. Because the simulator doesn't report a version for the ribbon, I just insert 4.2.1 for the sim.
Code:
String ver = null;
ApplicationManager appMan
= ApplicationManager.getApplicationManager();
ApplicationDescriptor[] appDes
= appMan.getVisibleApplications();
//check for the version of a standard
//RIM app. I like to use the ribbon
//app but you can check the version
//of any RIM module as they will all
//be the same.
// Also, **** RIM with a chainsaw.
int size = appDes.length;
for (int i = 0; i < size; i++){
if ((appDes[i].getModuleName()).equals("net_rim_bb_ribbon_app")) {
ver = appDes[i].getVersion();
break;
}
}
if (null == ver || ver.equals(""))
ver = "4.2.1"; // wild guess
int dots = 0;
int dotindex = 0;
while (-1 != (dotindex = ver.indexOf('.', dotindex))) {
dots++;
dotindex++;
}
while (dots > 2) {
ver = ver.substring(0, ver.lastIndexOf('.'));
dots--;
}
I know, it seems convoluted, but it's battle-tested.