Retrieve the BlackBerry Device Software version

by Retired ‎02-16-2010 10:15 AM - edited ‎02-17-2010 10:46 AM (3,495 Views)

Summary


This article applies to the following:

  • BlackBerry® smartphones based on Java® technology
  • BlackBerry® Device Software


Description


The following samples demonstrate how to obtain the BlackBerry Device Software version:

  • For BlackBerry JDE 4.3 and later

    Include the following single method call:


    DeviceInfo.getSoftwareVersion();


    Note: To use this method the BlackBerry smartphone must be running BlackBerry Device Software 4.3 or later and the application must be compiled with BlackBerry® Java® Development Environment (BlackBerry JDE) 4.3.0 or later.


  • For BlackBerry JDE 4.2 and earlier


  • import java.lang.*;

    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;

    class AppVersionSample extends UiApplication {

    public static void main (String[] args){
    AppVersionSample theApp
    = new AppVersionSample();
    theApp.enterEventDispatcher();
    }
    AppVersionSample(){
    MainScreen screen = new MainScreen();
    screen.setTitle
    (new LabelField("Apps Version Sample"));

    //USING THE APPLICATION MANAGER
    //(RUNNING APPS)
    //get the ApplicationManager
    ApplicationManager appMan
    = ApplicationManager.getApplicationManager();

    //grab the running applications
    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.
    int size = appDes.length;

    for (int i = size-1; i>=0; --i){
    if ((appDes[i].getModuleName()).
    equals("net_rim_bb_ribbon_app")){
    screen.add(new RichTextField
    ("Apps Version (by apps) = "
    + appDes[i].getVersion()));
    }
    }

    //USING THE MODULE MANAGER
    // (LOADED MODULES)
    //grab the module handles
    int[] handles
    = CodeModuleManager.getModuleHandles();

    size = handles.length;

    //check for a particular RIM module
    //(again I will use the ribbon app)
    for (int i = size-1; i>=0;--i){
    if (CodeModuleManager.getModuleName
    (handles[i]).equals
    ("net_rim_bb_ribbon_app")){
    screen.add(new RichTextField
    ("Apps Version (by module) = "
    + CodeModuleManager.getModuleVersion
    (handles[i])));
    }
    }
    pushScreen(screen);
    }
    }