2

What I am looking for:

I want to package my Application for different blackberry os versions (5,6 and 7). So that the user doesn't have to know what version he needs and just installs the app from the website.

What I have already found out:

  • I need to look in the web directory (there are three directories atm. one for each version)
  • I need a JAD file instead of an alx file, since it's a web-distribution (also in web there is no alx so that's fine so far)

What I think is my problem:

I do not know how to package those three directories in the web directory. I think I need just one folder and a JAD file that somehow manages what version of my app is being installed?

Can you please give me some insights.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Sven
  • 6,288
  • 24
  • 74
  • 116

1 Answers1

4

If your app only uses the OS5 API

If you develop your app using the OS5 BlackBerry JRE (Java Runtime Environment) then it will run on all devices running OS5, 6 and 7. The BlackBerry OS is backward compatible with previous OSs, so you don't have to worry about packaging for individual OS versions.

As far as packaging the app up, you just need to upload the appname.jad and appname.cod files in deliverables/Standard/5.0.0 to your web server, then direct your users to it from their BB phone, they should be prompted to download and install it.

If your app uses multiple APIs

You will need to distribute a cod and jad file for each API version you are using. Upload these to your web server then use a script to detect the user's OS version. Here's a PHP script to do this:

<?php 

$strUserAgent = $_SERVER['HTTP_USER_AGENT'];

if (strpos($strUserAgent, "BlackBerry") !== FALSE){

$blnOSFound = false;

echo "This is a BlackBerry.";

/**
 * BlackBerrys have 2 user agent string formats, check for both:
 *
 * Mozilla/5.0 (BlackBerry; U; BlackBerry 9860; en-GB) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.296 Mobile Safari/534.11+
 * BlackBerry9700/5.0.0.351 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/123
 *
 */
$arrAgentParts = explode(" ", $strUserAgent);

for ($i=0;$i<count($arrAgentParts);$i++){

    $strAgentPart = $arrAgentParts[$i];
     if (strpos($strAgentPart, "BlackBerry") === 0 &&
        strpos($strAgentPart, "/") !== FALSE){

        $intPositionOfSlash = strpos($strAgentPart, "/"); 
        $strOSVersion = substr($strAgentPart, $intPositionOfSlash+1, strlen($strAgentPart));
        $blnOSFound = true;
        break;

    } else if (strpos($strAgentPart, "Version") === 0){
        $intPositionOfSlash = strpos($strAgentPart, "/"); 
        $strOSVersion = substr($strAgentPart, $intPositionOfSlash+1, strlen($strAgentPart));
        $blnOSFound = true;
        break;            
    }
}

if ($blnOSFound){
    echo " OS Version: ".$strOSVersion;

    $intMajorOSVersion = substr($strOSVersion, 0, 1);

    //Redirect user to the jad file for their OS version
    switch ($intMajorOSVersion){

    case 5:
        Header("Location: 5.0.0/myapp.jad");
        break;  
    case 6:
        Header("Location: 6.0.0/myapp.jad");
        break;
    case 7:
        Header("Location: 7.0.0/myapp.jad");
        break;
    default:
        echo "Unsupported OS version";
        break;
    }

} else {
    echo " Could not find OS version";
}

} else {
echo "Not a BlackBerry";
}

?>

You might want to hack around with this a bit to remove the echo statements.

When developing your app for multiple APIs there are 2 approaches:

  1. Maintain separate projects for each API version and use a common library of code which will run on all APIs to avoid duplicate code
  2. Define preprocessor directives in your BlackBerry_App_Descriptor.xml to conditionally include code based on the target OS. You will need to change the referenced BlackBerry JRE each time you change target OS (In Eclipse: Properties->Java Build Path->Libraries).
donturner
  • 17,867
  • 8
  • 59
  • 81
  • what if the app uses newer APIs on newer OS versions, though? For instance, I am working on an app that makes use of version-specific APIs in some places (mostly for utilizing newer UI controls when available), so I have multiple versions that are compiled for different JRE versions. What would be the correct way to package that kind of app up for easy distribution? – Remy Lebeau Nov 18 '11 at 01:57
  • I've updated my answer to cover this, sorry I thought from your original question that you were only looking to build using one API. One the whole building for multiple APIs is a bit of a pain so only do it if you absolutely must! – donturner Nov 18 '11 at 10:24
  • thanks for the update. I am using the preprocessor approach in my project. – Remy Lebeau Nov 18 '11 at 19:10
  • btw, I'm not the OP, but the OP's question applies to me, as I will likely be pursuing OTA downloads for the initial release of my app. – Remy Lebeau Nov 18 '11 at 19:25
  • ah right, well I hope the answer helped, any chance of an upvote? – donturner Nov 19 '11 at 19:58