Hello BlackBerry

In this section, you'll see the basics of how RIMlets work by creating a Hello World'' RIMlet. Note The term RIMlet is an informal name that you'll see in discussions on the Internet, but it doesn't appear in RIM's official documentation. As you'll see in the sections on compiling and building your application, RIM uses the term CLDC application for BlackBerry applications that aren't MIDlets. This choice of terminology is confusing because a MIDlet is also a type of CLDC application. Since...

Understanding BlackBerry Application Files

Once you build your project using one of the build options under the project menu , the BlackBerry build tools will create a series of files. Some of these files are standard MIDP files, and some are BlackBerry specific. The JARfile extension .jar is the main application file for MIDP. It's the file containing the resources and compiled class files to run on the device. It's a standard Java Archive file with the added requirement that the manifest file META-INF MANIFEST.MF in the JAR file has...

A Quick Introduction to USB

USB Universal Serial Bus communication is carried out between a host and its devices. Usually the host is a PC or laptop, and devices their peripherals, such as printers, hard drives, and keyboards. The host detects devices, manages data flow on the communications bus, carries out error checking, and often provides power to the devices. In this chapter, the host is the PC running the BaseStation application, and the device is the Dream Cheeky garage and car. A device is uniquely identified by...

From Mercator to Image Coordinates

Mercator Projection

Google maps use a Mercator cylindrical projection to flatten the earth's surface onto a 2D map, as illustrated by Figure 11-12. Longitudes are mapped linearly to the x-axis, but latitudes are increasingly spaced out the further they are from the equator. This increasing distortion means that Google Maps only utilizes the Mercator projection between latitudes 85.05113 degrees north and south, which explains why some parts of the polar regions are missing in Figures 11-8 and 11-12. Figure 11-12....

Ion lat xy

Figure 11-15. Converting latitude to a y-coordinate In Figure 11-15, the y-axis Mercator map distance between the player coordinate and the center is invGud lat - invGud latc . This is equivalent to the pixel distance invGud lat -invGud latc latConvert. Therefore, the y-axis distance from the top of the image down to the coordinate is IM_HEIGHT 2 - invGud lat - invGud latc latConvert. This calculation is implemented in the MapCoords class as the method lat2y private static final double LAT_MAX...

Building the Tweet Space Game Logic

The next step is to design the game itself. For BlackBerry smartphones that have operating system version 4.6.0 and greater, the game will open with the SVG Space Explorer animation from Chapter 8. But to keep this game compatible with the rest of the BlackBerry smartphones out there, the rest of the game will use a more standard, sprite-based implementation rather than using the SVG Space Explorer game logic . Let's start with an overview of the net.frogparrot.tweetspace package, shown in...

Using a MessageConnection

Listing 7-1 shows how to open a MessageConnection and use it to send and receive messages. Both sending and receiving are operations that need to be run on a separate thread, notthe event thread. As you can see in Listing 7-1, when a new message arrives for the MessageConnection, the BlackBerry platform uses the event thread to call notifyIncomingMessage on the connection's MessageListener which this class has been set to be , indicating which MessageConnection has a new message waiting. This...

User Input

The game supports four types of user input device shaking through the accelerometer, clicking the screen, trackball movement, and key presses. They are translated into left and right saber rotations across the screen. I've already discussed accelerometer processing, which utilizes polling in processShakes , and calls LightSaber.shake to rotate the saber. Touch, trackball clicks, and key presses are handled by overriding their relevant listener methods inherited from FullScreen. private volatile...

Creating Resource Files

In order to be sure that your game's labels and texts are presented to the user in the correct language, you need to create a set of localized data files that map a set of key constants to the sets of strings to display. To create the resource bundle and generate the corresponding resource interface, the BlackBerry build tool needs a resource header file with the extension .rrh and a set of resource files with the extension .rrc , one for each of the locales that your application supports....

Time for an Example CurrentTime

The CurrentTime servlet implements a time-of-day service. A browser or stand-alone application can contact it by referring to the servlet's URL, which is converted into a GET request sent to the Java EE server managing the servlet. The situation is illustrated by Figure 11-6. Figure 11-6. Calling CurrentTime from a browser My departmental Java EE server Apache Tomcat stores my servlets at The CurrentTime servlet can be reached with the URL as shown in Figure 11-7. Figure 11-7. CurrentTime in...

Laying Out the Screen with a Manager

The first step is to create a custom Manager Listing 4-2 , designed specifically to draw the user interface screen. This is a custom layout manager to draw the look and feel class SelectSizeManager extends Manager Dimension constants depend on the screen size public static final int OUTLINE 0x00025cb8 public static final int DK_BLUE 0x00037ffd public static final int MED_BLUE 0x0066b0fb public static final int LT_BLUE 0x00c7e2fd public static final int BLACK 0x00000000 Constructor initializes...

C

direction constants, 461 modes, 457-462 moving, 457 rotating, 454-456 translating, 456-457 Camera class, 419, 453, 457 Camera instance, 460 Camera object, 453, 461 Camera.move method, 453, 457 Camera.reset method, 453 Canvas class, 59, 229, 312 Canvas component, 254 CarController client, 347 CarControls class, 350-351, 355, 358, 361 CarControls client toy car project, Java version, 358-362 CarControls method, 352, 354 CarControls RIMlet, 350-358 buttons creation, 355-357 presses and releases,...

The Netbook Version of CarControls

Class Diagram Buttonpanel

As explained at the start of this chapter, there s no real need for a Java SE version of the CarControls client, but it s useful for debugging and testing the server. Figure 10-25 shows the GUI for BlueCarControls the Java SE code , which replicates the look of CarControls fairly closely see Figure 10-21 . Figure 10-25. The BlueCarControls GUI Figure 10-25. The BlueCarControls GUI Class diagrams for BlueCarControls are shown in Figure 10-26, and should be compared to the diagrams for...

Sending Dynamic Keys to BlackBerry App World

If you d like to generate a user-specific license key, and you want BlackBerry App World to sell it to the user for you, then you ll need to dynamically transfer the keys to BlackBerry App World. Fortunately, RIM has defined a simple protocol for this transaction, found in a document called Dynamic License Flow, which you can download here All you need to do is set up a web server to accept a simple HTTP POST command from BlackBerry App World containing the user s data and then return the...