In addition to full support of standard CLDC and MIDP APIs, RIM provides BlackBerry-specific extensions that enable you to develop applications with the look and feel of native applications. The BlackBerry APIs provide tighter integration for BlackBerry devices, and access to BlackBerry features for user interface, networking, and other capabilities.
Generally, you can use CLDC, MIDP, and BlackBerry APIs together in the same application – with the notable exception of user-interface APIs. A single application should not use both the javax.microedition.lcdui
and net.rim.device.api.ui
packages. RIM's UI APIs provide greater functionality and more control over the layout of your screens and fields, but at a cost: Resulting MIDlets will be non-standard, so porting to other platforms will require more effort.
Unlike MIDP's UI classes, RIM's are similar to Swing in the sense that UI operations occur on the event thread, which is not thread-safe as in MIDP. To run code on the event thread, an application must obtain a lock on the event object, or use invokeLater()
or invokeAndWait()
– extra work for the developer, but sophistication comes with a price tag.
Your choices come down to these: You can develop your application as a standard MIDlet that will run on any MIDP-enabled device, or as a RIMlet, a CLDC-based application that uses BlackBerry-specific APIs and therefore will run only on BlackBerry devices. If you're developing solely for the BlackBerry you should use the CLDC model because the RIM APIs will give you the BlackBerry-native look and feel – without denying you the option to use J2ME-standard APIs in areas other than UI. For persistence, you can use BlackBerry's APIs or the MIDP RMS APIs; if you're already familiar with RMS, use it. For networking, use the Generic Connection Framework.
The main class of a RIMlet extends either net.rim.system.Application
, if it's a background application with no user interaction, or net.rim.system.UiApplication
if the RIMlet needs a user interface. Unlike a MIDlet's starting point, the entry point into a RIMlet is the main()
method. As in the MIDP UI, a RIMlet screen is not a movable window. To display it you simply push it on the display stack using pushScreen()
. I'll show you an example later.
No comments:
Post a Comment