How To - Programmatically read the attributes of a JAD file

Summary

This article applies to the following:

BlackBerry® Device Software 4.3 and later BlackBerry smartphone

Details

When publishing an application over the wireless network, the application developer may need to access the contents of the corresponding Java® Application Descriptor (JAD) file to read attributes embedded in the file.

The following is a sample JAD file:

Manifest-Version: 1.0
MIDlet-Version: 1.0.1
MIDlet-Name: My App
MIDlet-Description: My description
MIDlet-Vendor: My Company, Inc.
RIM-COD-Module-Name: Sample JAD
RIM-COD-URL-1: FileOne.cod
RIM-COD-Size-1: 20000
RIM-COD-URL-2: FileTwo.cod
RIM-COD-Size-2: 10000
My-Custom-JAD-Property: Hello There!

In BlackBerry Device Software 4.3 and later, the BlackBerry smartphone introduces support for programmatically reading the contents of the JAD file added or modified after the application has been built. This allows a developer to add dynamic content to a JAD file that could be unique for a particular user or installation.

Custom JAD attributes can be read prior to JAD version 4.3.0. However, the custom JAD file attributes must be added to the JAD file before build time and cannot be modified after the application has been built. To accomplish this the JAD file must be added to the project in the BlackBerry Java® Development Environment (BlackBerry JDE) or BlackBerry® JDE Plug-in for Eclipse™. This means that the custom attribute is identical for all BlackBerry smartphone users who install the application and are using BlackBerry Device software 4.3.0 or earlier.

For a MIDlet, JAD file attributes can be read by calling MIDlet.getAppProperty(). For a Connected Limited Device Configuration (CLDC) application that is leveraging the BlackBerry smartphone application programming interfaces (API), JAD file attributes can be read by callingCodeModuleGroup.getProperty(). Examples for each application type are provided below.

MIDlet example:

String description = MIDlet.getAppProperty("MIDlet-Description");
String custom = MIDlet.getAppProperty("My-Custom-JAD-Property");

BlackBerry smartphone API example:

CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
CodeModuleGroup myGroup = null;
String moduleName = ApplicationDescriptor
   .currentApplicationDescriptor().getModuleName();

for (int i = 0; i < allGroups.length; i++) {
   if (allGroups[i].containsModule(moduleName)) {
      myGroup = allGroups[i];
      break;
    }
}

// Get the property
String description = myGroup.getProperty("MIDlet-Description");
String custom = myGroup.getProperty("My-Custom-JAD-Property");

For more information on JAD files and publishing applications over the wireless network, see theDeploying Java Applications whitepaper.

Note: Auto-start applications that read JAD file attributes should implement a short delay (approximately 1 second) before attempting to read JAD file attributes on its first startup. When an auto-start application is installed it will start up in parallel to the BlackBerry smartphone saving the JAD file information. This can result in a race condition where the application tries to read the attributes before they have been saved, resulting in a failure to access the attributes. This only occurs the first time an application is installed and the BlackBerry smartphone is not restarted during the installation.

 

Keywords

deploy, OTA, over the air, JAD, property, read, application, descriptor, MIDlet, CLDC, getAppProperty, CodeModuleGroup

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值