You need creativity, Java programming skills, and patience to implement, refine, and deliver your BlackBerry application. Your BlackBerry application development efforts require you to come to grips with (among other things) making sure that the Java Development Environment (JDE), your simulator, and device versions are compatible; implementing basic application classes; and wisely using callbacks.
>
>
Matching BlackBerry JDE, Simulator, and Device Versions
The BlackBerry Java Development Environment (JDE) is available in several versions. The version number of the JDE is directly related to the version of the OS running on the smartphones where your app will reside. Selecting the JDE version is a critical and careful step to take in your path to delivering your BlackBerry app.
Keep these ideas close at hand:
Functionality available in one OS version might not be available in a prior version. For example, the BlackBerry Storm (OS 4.7) smartphone includes touchscreen and accelerometer application programming interfaces (APIs) that are not available in earlier OS versions written for BlackBerry devices without that hardware. In this case, you need to test your app on the Storm simulators, so you know what your users will experience when they install it on their touchscreen BlackBerry smartphones. With the BlackBerry App World, you can deliver a different version of your app that's optimized for a touchscreen device, so that's another option to keep in mind.
An application written for a current OS version might not execute on a BlackBerry smartphone running an earlier version. This is true even for simple applications. Even if both OS versions have the exact same APIs, the code itself might be located in different places in the libraries, which will break your application when it tries to run. In this case, you need to make sure your app only loads onto smartphones that have the same version of the OS that your app was built for, or later. And you can do this when you submit your app to the BlackBerry App World.
Similarly, an application written for a current OS version might not execute on a future version, for the same reasons. However, you can reasonably assume that your BlackBerry application will execute without rebuilding for several major OS versions into the future. In this case, you need to keep track of the RIM smartphone OS releases, and run your app on a simulator or two that uses newer OS versions. You will discover issues either on your own or through feedback at the BlackBerry App World - and it's always better if you find problems before your users do.
Simulators installed with the JDE will work with that JDE; however, simulators downloaded directly from the BlackBerry developer site might not function properly when launched from a JDE because the JDE's debugger expects to find particular RIM libraries that aren't available. In this case, you need to tell the debugger to continue and ignore the missing library.
>
>
>
Implementing Basic Java Application Classes for a BlackBerry App
Your BlackBerry application starts off from a blank slate. The Java Development Environment (JDE) creates an empty workspace, and you will add a project and Java source files. You need to implement subclasses of some basic BlackBerry library classes to create a full-fledged application:
net.rim.device.api.ui.UiApplication: This is your application class, which is the overseer of your BlackBerry application's contents. You'll usually implement a main method within this class as well.
net.rim.device.api.ui.container.MainScreen: Your BlackBerry application shows several screens of information to users. You subclass MainScreen to provide a basic display for them to see.
net.rim.device.api.ui.MenuItem: Users expect to perform some navigation by using menus, and you support their expectations by creating subclasses of MenuItem to provide menu-selection functionality. Your BlackBerry application can do this inline by creating a new MenuItem object and adding specific methods to the object during its creation. Note that if you're making the same MenuItem over and over, you should seriously think about creating a real subclass for it.
net.rim.device.api.ui.Manager: This class is useful when you want to lay out the components of a MainScreen subclass in a specific, controlled formation. MainScreen comes with a particular Manager subclass — VerticalFieldManager — as default. But it's pretty vanilla-boring, so you might want to think about creating your own.
net.rim.device.api.system.Persistable: Your BlackBerry application will very likely be storing users' data, and this is the interface that you need to implement in your classes that store the data in a PersistentStore.
java.lang.Thread, Runnable: You have to subclass these in certain situations where your BlackBerry application performs some long-duration operation, such as trading information with a network service or communicating via a Bluetooth peripheral. In addition, certain classes you provide to the BlackBerry OS, such as MenuItem, incorporate threaded behavior as part of their operation. MenuItem requires you to implement a run() method, which is launched as a separate Thread when the user selects your MenuItem.
>
>
>
Keeping a Close Eye on BlackBerry App Callbacks
Your BlackBerry application uses callbacks to allow the smartphone's OS to call into your application for specific operations. Your BlackBerry application itself likely employs callbacks to allow the threads it creates to inform the main process of your application that the thread has completed its job.
Here are a few things to keep in mind when dealing with callbacks:
Implement your BlackBerry application's callbacks as an interface, not a class. This allows you the flexibility to make any concrete class already in your application an object that can receive the message from the thread.
Provide both success and failure methods in your callback implementation. You should program as if something bad will happen so you'll be prepared when it does, such as a failure to reach a network service or a BlackBerry running low on memory unable to download a large file.
If your callback is going to modify what's on display or interact with the user, place the code to be executed within a Runnable object and pass that object into a call to UiApplication.invokeLater( Runnable r ).
>
>
dummies
Source:http://www.dummies.com/how-to/content/blackberry-application-development-for-dummies-che.html
No comments:
Post a Comment