I mentioned this topic earlier, but it deserves a little more discussion now. Using the JDE or the JDE Plug-in for Eclipse, you can create several types of BlackBerry projects. We’ve been making applications up to this point, but there are two others that you may end up using: libraries and alternate entry points.
Libraries, like applications, are packaged as .cod files. They’re loaded onto a device in the same way. The difference is that they aren’t executed directly by the BlackBerry; they contain code or resources used by one or more other applications. You may want to create a library to logically separate your code or to reuse code between applications.
Creating a Library
Creating a library is similar to creating an application. From Eclipse you create a BlackBerry project as normal, and then from the Project Properties, select Library.
Making a BlackBerry application into a library in Eclipse
From the JDE, simply select Library from the “Create new file” dialog.
Creating a new Library in the JDE
Using Libraries in Your Application
Once you have a library, you need to tell your development environment that your application depends on it. From the JDE, this is accomplished through the Project ➤ Dependencies menu item. From Eclipse, the option is buried a little deeper, under project Properties, select Project References, as shown in Figure.
Adding a library dependency from Eclipse
Once you’ve added the library dependency to your project, you can refer to classes in that library in the same way as you refer to classes in your application.
NOTE: A warning about duplicate classes on the BlackBerry.The BlackBerry class loader uses one global namespace. This means that having two classes in two different modules have the exact same fully qualified class name will cause a conflict. Having two classes both named.HelloWorldMainScreen is a problem, but if one is named .HelloWorldMainScreen, that’s OK. Libraries can help you get around naming conflicts like this by moving common code into one place, but they can also cause problems if you’re not careful and have the same classes included in a library and in your application.
Creating an Alternate Entry Point
An alternate entry point is exactly what it sounds like—another way for the user or BlackBerry to start your application. An alternate entry point can provide another icon on the BlackBerry home screen to start your application. By clicking on the other icon, the same main method is called, but with different parameters, allowing you to run your application in different modes.Alternate entry points are also commonly used with applications that are configured to automatically start when the device powers on or reboots, but that may also need to be started by the user or might be integrated into other applications, such as the Messages or Camera application, and started using a menu item in one of those applications.
The process for creating an alternate entry point is fairly similar between the JDE and the JDE Plug-in for Eclipse, so we’ll just go over the Eclipse method in this. In the Hello World workspace, create a new BlackBerry project called HelloWorldAlternate, and open the BlackBerry Project Properties dialog. The Application tab will have a couple of new entries, one of which is Alternate CLDC Application Entry Point. Select that, and the “Alternate entry point for” drop-down will become enabled, letting you select HelloWorld as the project.
Creating an alternate entry point for the Hello World application
Let’s modify the application a little, so you can see the alternate entry point at work. In the Arguments box, type alt and click OK. Now, add a new constructor to
Modify the main method and the constructor in HelloWorldApp to look at the parameters passed in, and call the alternate constructor if alt is the first one:
In the new HelloWorldApp constructor, we first check the length of args. The BlackBerry device will split the argument string that we specified in the project properties for our alternate entry point into words based on whitespace, and place each word into a separate element of the array.Since we didn’t specify any arguments for the main HelloWorld project, args will have a length of 0. Now when you run the simulator, you’ll see a HelloWorldAlternate icon on the home screen. Click it, and you’ll see Goodbye World.
Running Hello World through an alternate entry point
MIDP and MIDlet Projects
Finally, you may have noticed the MIDlet project type in the Eclipse Plug-in or the JDE. In case you’re not familiar with Java ME programming, a MIDlet is the application type for the Java ME Mobile Information Device Profile (MIDP), which is essentially a set of classes and capabilities that most Java ME implementations support. Many other types of smartphones from companies such as Nokia, Sony Ericsson, and Motorola support MIDP. You would use MIDP to build applications that run on all these devices without any code changes. The BlackBerry fully supports MIDP but also includes a large API that’s not part of MIDP.
This means that the BlackBerry can run MIDlets, and in fact, MIDlets that are specifically built for BlackBerry can access many parts of the non-MIDP API, but they don’t have access to the entire BlackBerry API. Specific things that MIDlets do not have access to include the BlackBerry UI API and the BlackBerry application life cycle controls (like automatic start). For these reasons, I recommend that you not write your BlackBerry applications as MIDlets, and in fact, I don’t discuss MIDlet-specific topics in this after this section. However, if you have an existing MIDlet originally built for another smartphone platform and you need to quickly run it on a device, BlackBerry has you covered.
BLACKBERRY Related Interview Questions
|J2ME Interview Questions||BLACKBERRY Interview Questions|
|Android Interview Questions||Retail Interview Questions|
|Telecommunication Project Management Interview Questions||Mobile Testing Interview Questions|
|Telemarketing Interview Questions||Mobile Application Testing Interview Questions|
|Mobile Marketing Interview Questions||Telecom Billing Interview Questions|
|Mobile Application Architect Interview Questions|
Setting The Stage
What Makes A Blackberry Application?
User Interface Basics
Beyond The Basics Of User Interfaces
Hello Out There! Making A Network-enabled Application
Where Am I? Using Location-based Services
Getting Your App Out There: Packaging And Publishing
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.