使用 JAD 文件为不同操作系统版本打包 Blackberry 应用程序

发布于 2024-12-16 14:51:10 字数 377 浏览 2 评论 0原文

我在寻找什么:

我想将我的应用程序打包为不同的黑莓操作系统版本(5,6 和 7)。这样用户就不必知道他需要什么版本,只需从网站安装应用程序即可。

我已经发现:

  • 我需要查看 web 目录(atm 有三个目录,每个版本一个)
  • 我需要一个 JAD 文件而不是 alx 文件,因为它是一个 web-发行版(在网络中也没有alx,所以到目前为止还好)

我认为是我的问题:

我不知道如何将这三个目录打包在网络目录中。我想我只需要一个文件夹和一个 JAD 文件来以某种方式管理正在安装的应用程序版本?

你能给我一些见解吗?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┼── 2024-12-23 14:51:10

如果您的应用程序仅使用 OS5 API

如果您使用 OS5 BlackBerry JRE(Java 运行时环境)开发应用程序,那么它将在运行 OS5、6 和 7 的所有设备上运行。BlackBerry OS 向后兼容与以前的操作系统兼容,因此您不必担心各个操作系统版本的打包问题。

至于打包应用程序,您只需将 Deliverables/Standard/5.0.0 中的 appname.jad 和 appname.cod 文件上传到您的 Web 服务器,然后引导您的用户从他们的 BB 手机访问它,他们应该会得到提示下载并安装它。

如果您的应用使用多个 API

您将需要为您使用的每个 API 版本分发一个 cod 和 jad 文件。将它们上传到您的网络服务器,然后使用脚本来检测用户的操作系统版本。下面是执行此操作的 PHP 脚本:

<?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";
}

?>

您可能需要对此进行一些修改以删除 echo 语句。

为多个 API 开发应用程序时,有 2 种方法:

  1. 为每个 API 版本维护单独的项目,并使用将在所有 API 上运行的通用代码库,以避免重复代码
  2. 在 BlackBerry_App_Descriptor.xml 中定义预处理器指令,以有条件地包含基于以下条件的代码:目标操作系统。每次更改目标操作系统时,您都需要更改引用的 BlackBerry JRE(在 Eclipse 中:属性 -> Java 构建路径 -> 库)。

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).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文