Lubos Mobile Development Blog

Lubos Mobile Development Blog

Getting BlackBerry OS Version

Posted by lubosp on January 19, 2010

It might be handy to get BlackBerry OS version when developing for multiple versions of BlackBerry OS. Following is slightly modified code I took BlackBerry Forums (sorry cannot find the post, but all the credit goes to the original author of the post):

    public static String getOSVersion() {
        String swVersion = null;
        ApplicationManager appMan = ApplicationManager.getApplicationManager();
        ApplicationDescriptor[] appDes = appMan.getVisibleApplications();

        int size = appDes.length;
        for (int i = 0; i < size; i++){
            if ((appDes[i].getModuleName()).equals("net_rim_bb_ribbon_app")) {
                swVersion = stripBuildId(appDes[i].getVersion());
                break;
            }
        }
        return swVersion;
    }

    public static int[] getOSVersionInt() {
        String version = getOSVersion();        
        Vector result = new Vector();
        int num = version.length();
        int start = 0;
        int end = 0;
        for (int i = 0; i < num; i++) {
            char ch = version.charAt(i);
            if (ch == '.' || i == num - 1) {
                end = (i == num - 1) ? i + 1 : i;
                result.addElement(version.substring(start, end));
                start = end + 1;
            }
        }
        num = result.size();
        int[] resultArr = new int[num];
        for (int i = 0; i < num; i++) resultArr[i] = Integer.parseInt((String)result.elementAt(i));
    	
        return resultArr;
    }
    
    public static String getUserAgent() {
        String version = getOSVersion();
        return "BlackBerry" + DeviceInfo.getDeviceName() + "/" + version + " "
        + "Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/" + Branding.getVendorId();
    }
    
    private static String stripBuildId(String version) {
        int index = version.lastIndexOf('.');
        return version.substring(0, index);
    }

Posted in BlackBerry | Tagged: , | Leave a Comment »

BlackBerry models table with screen resolution and supported operating system

Posted by lubosp on January 13, 2010

Following table lists BlackBerry devices, their screen resolution, interaction, supported operating system and icon sizes:

Model Resolution Interaction OS Icons

BlackBerry® 7100 Series

240 x 260

trackwheel  

• Icon layout: 60 x 55 pixels
• Zen layout: 48 x 36 pixels

BlackBerry® 8700 Series

320 x 240

trackwheel

4.2.1

• Icon layout: 53 x 48 pixels
• Zen layout: 48 x 36 pixels

BlackBerry® 8800 Series

320 x 240

trackball 4.5.0

• Icon layout: 53 x 48 pixels
• Zen layout: 48 x 36 pixels

BlackBerry® Bold™ 9000
smartphone

480 x 320

trackball 4.6.0 80 x 80 pixels

BlackBerry® Curve™ 8300 Series

320 x 240

trackball 4.5.0

• Icon layout: 53 x 48 pixels
• Zen layout: 48 x 36 pixels

BlackBerry® Curve™ 8350i
smartphone
BlackBerry® Curve™ 8500 Series

320 x 240

trackpad 4.6.1 52 x 52 pixels

BlackBerry® Curve™ 8900
smartphone

480 x 360

trackball 4.6.1 80 x 80 pixels

BlackBerry® Pearl™ 8100 Series

240 x 260

trackball 4.5.0

• Icon layout: 60 x 55 pixels
• Zen layout: 48 x 36 pixels

BlackBerry® Pearl™ Flip 8200 Series

240 x 320

trackball

4.6.0

46 x 46 pixels

BlackBerry® Storm™ 9500 Series

360 x 480

touch screen 5.0.0 73 x 73 pixels

BlackBerry® Tour™ 9600 Series

480 x 360

trackball 4.7.1 80 x 80 pixels
BlackBerry® Bold™ 9700 smartphone   trackpad 5.0.0 80 x 80 pixels

 

Posted in BlackBerry | Tagged: , | Leave a Comment »

How to capture swipe gestures events on BlackBerry with touch screen

Posted by lubosp on January 12, 2010

Following code captures swipe gestures events on touch screen BlackBerry like Storm:

protected boolean touchEvent(TouchEvent message) {
  switch(message.getEvent()) {
  case TouchEvent.GESTURE:
    TouchGesture gesture = message.getGesture();
     switch(gesture.getEvent()) {
     case TouchGesture.SWIPE:
       if(gesture.getSwipeDirection() == TouchGesture.SWIPE_EAST) {
         Dialog.alert("Eastward swipe occurred");
         return true;
       } else if(gesture.getSwipeDirection() == TouchGesture.SWIPE_WEST) {
         Dialog.alert("Westward swipe occurred");
         return true;
       }
     }
  }
  return super.touchEvent(message);
}

touchEvent method should be implemented for a screen that wishes to process swipe gestures, see TouchEvent Javadoc for details.

Posted in BlackBerry | Tagged: , | Leave a Comment »

How to set Http connection timeout for BlackBerry

Posted by lubosp on January 12, 2010

BlackBerry API uses Connection class to establish http connection like:

HttpConnection hc = null; try {
   hc = (HttpConnection) Connector.open(url, Connector.READ, true);
   hc.setRequestMethod(HttpConnection.GET);
   int response = hc.getResponseCode();

The problem is that if the connection cannot be established, it takes 2 min for a connection to timeout. To change the default timeout value, you can use url parameter ConnectionTimeout like:

hc = (HttpConnection) Connector.open(url + &quot;;ConnectionTimeout=10000&quot;, Connector.READ, true);

which sets the connection timeout to 10 second (in milliseconds).

Posted in BlackBerry | Tagged: , | 2 Comments »

Lubos Mobile Development Blog

Posted by lubosp on January 11, 2010

This blog is intended to capture my experiences with developing mobile applications in Java for smartphones. Mainly for BlackBerry platform, and hopefully for Android in the future. I am not big fan of iPhone and I do not own Mac, so iPhone development is probably out of question.

Posted in Android, BlackBerry, mobile | Tagged: , , , | Leave a Comment »