Handling Stylus Events

Stylus events can be detected using the Canvas class, which provides developers with methods to handle pointer events Canvas.hasPointerEvents indicates whether the device supports pointer press and release events e.g., when the user touches the screen with a stylus . indicates whether the device supports pointer motion events e.g., when the user drags the pointer . Canvas.pointerDragged int x, int y is called when the pointer is dragged. Canvas.pointerPressed int x, int y is called when the...

Enter Java ME on Symbian OS

Once you've read Part Two, you can proudly claim that you understand Java ME on Symbian OS. Thinking about it, why can't you do that already As you noticed, no new tricks were mentioned in Chapter 2. Java is Java, ME is ME and it is all too familiar. Even suspiciously familiar How can Java ME on Symbian OS be the same as everywhere yet more than anywhere And at the same time Well, it is true Just to confirm again, Java ME on Symbian OS is still Java ME. Only, there's much more Chapter 2 defined...

Debrief Summary

So far we have discovered two important concepts regarding game development with Java ME It is really easy to write Java games. It is really easy to write Java games badly. This is not all that surprising. The vast majority of mobile phones in the mass market at the time MIDP 2.0 was designed had a number of built-in limitations. So MIDlets did not have much memory, little local storage space and were rarely paused. Few mobile-phone operating systems are multitasking and MIDlets that lose focus...

Packaging a MIDlet

Following the above steps is sufficient to build simple MIDlets for running in the emulator. However, if you are developing a more sophisticated MIDlet that contains many classes, images, application parameters, and so on, you need to package your MIDlet into a MIDlet suite. Packaging creates a JAR file containing all your class and resource files such as images and sounds and the application descriptor JAD file, which notifies the AMS of the contents of the JAR file. The following attributes...

Developing a MIDlet

Once the source code has been written, we are ready to compile, pre-verify and package the MIDlet into a suite for deployment to a target device or a device emulator. In this section, we create our first MIDlet in a simple but complete example of MIDlet creation, building, packaging and execution. We use a tool called the Java Wireless Toolkit WTK which provides a GUI that wraps the functionality of the command-line tool chain compiler, pre-verifier and packaging tool. The WTK see Figure 2.3...

Datagram Support

Symbian's MIDP implementation includes support for sending and receiving UDP datagrams. A datagram connection can be opened in client or server mode. Client mode is for sending datagrams to a remote device. To open a client-mode datagram connection we use the following URI format Here the port number indicates the port on the target device to which the datagram will be sent. Sample code for sending a datagram is shown below String message Hello byte payload message.toString...

Using OnDevice Debugging

The high-level setup instructions are to connect the device and the PC by Bluetooth or WLAN , start the DebugAgent on the device, start the Device Connectivity Tool, and run and debug from the IDE just as you do on the emulator. Depending on the S60 SDK version, the DebugAgent can also be called EcmtAgent. You set up the DebugAgent in the following way 1. Install the DebugAgent to your S60 device. The DebugAgent SIS file is delivered with the SDK and is located under the S60tools Ecmt...

Nokia UI API

The Nokia UI API has been available since the days of MIDP 1.0 and devices such as the Nokia 6600. Back then, MIDP 1.0 was the standard for ensuring maximum portability and concentrated only on features that could be implemented by all mass-market devices. Some of those devices had very limited graphics capabilities and sometimes no sound capabilities at all. The Nokia UI API was introduced to make such features available to Java applications on Nokia devices, which already had sound...

SDKs for Sony Ericsson SJP

Sony Ericsson's Java strategy has adopted a platform approach with two branches SJP supports phones that use Symbian OS and JP supports phones that do not use Symbian OS. Each Java Platform is used in several phone models to help developers focus on a family of devices rather than on a variety of different products. At the time of writing this book, there are three SJP platforms SJP-1, SJP-2 and SJP-3 , which are implemented through an evolutionary approach in order to ensure forward...

Integration with Native Services 1

It was clear from the beginning of Java ME on Symbian OS that LCDUI widgets must be mapped to native controls and rendering must use the Graphics subsystem frameworks. In addition, the tight integration with the Graphics subsystem and APPARC had to take into consideration the mandatory requirement for customization by Symbian licensees. The LCDUI integration with Graphics and APPARC can basically be characterized into two functionality areas common functionality inside a 'core framework' and...

Finding More Information

Before we finish this chapter, we give you some guidance on how to find answers to other questions you may have and how to find out information about other devices. You may need to develop a Java application or port it to another Symbian smartphone. What should be your approach when searching for information and where can you find information on a particular device As you have seen, technical competence is not enough when developing or porting a Java application to a Symbian smartphone. You...

Summary Acu

In this chapter, we discussed the integration of Java ME APIs with native Symbian OS services in order to ensure consistent user experience between Java applications and native applications. We have seen that there are a few types and levels of integration and that the likely approach to integration is to map Java functionality to native functionality. The two worlds are fundamentally different, therefore the integration has to handle numerous challenges, as we saw in the examples. Some...

LCDUI Interfaces

The user interface package, javax.microedition.lcdui, provides four interfaces that are available to both the high- and low-level APIs Choice defines an API for user-interface components, such as List and ChoiceGroup. The contents of these components are represented by strings and images which provide a defined number of choices for the user. The user's input can be one or more choices and they are returned to the application upon selection. CommandListener is used by applications that need to...

Socket and Server Socket Support

MIDP makes support for socket connections a recommended practice. Socket connections come in two forms client connections, in which a socket connection is opened to another host and server connections in which the system listens on a particular port for incoming connections from other hosts. The connections are specified using Universal Resource Identifiers URI . You should be familiar with the syntax of a URI from web browsing. They have the format lt string1 gt lt string2 gt where lt string1...

Launching Java ME Detectors

Figure 3.4 Main applications menu on a Nokia N95, b Nokia 58GG XpressMusic and c Sony Ericsson W96Gi Table 3.1 shows the results of running JSRsDetectorMIDlet. As you can see, all the reference devices support more JSRs than there are in the MSA subset. In fact, they are very close to supporting all MSA Component JSRs. These are not the only supported APIs we discuss other APIs later in the chapter. Table 3.1 Supported JSRs in Reference Phones Table 3.1 Supported JSRs in Reference Phones JSR-1...

Mandatory Integration JSR FileConnection

The FileConnection API is an optional package of JSR-753 that facilitates access to the device file system and removable media e.g., memory 3JSR-75 FileConnection implementation is under src common generic j2me components file in the Symbian OS source repository. cards . It supports the creation and removal of directories and files, IO operations on files, listing directory contents and getting file information. The two most important classes are FileSystemRegistry a central registry for...

Sprites Layers and Collision Detection

The game API has excellent support for sprites. A Sprite can be moved, positioned, flipped, and mirrored around both the horizontal and vertical axes or about an arbitrary point by using the defineRefer-encePixel method. A sprite can also be constructed from a single image consisting of a set of equally sized frames which can then be animated using the nextFrame and prevFrame methods. You can also use the collidesWith and defineCollision-Rectangle methods for collision detection between sprites...

Detecting Diversity using Properties

In Chapter 3, we used JSRsDetectorMIDlet to detect support for JSRs on Symbian smartphones. We use this technique again in Section 4.4. For now, there are other details about the Java ME subsystem that you probably want to find out. Another method of detecting device capabilities is by querying the system properties. System properties can be retrieved using the System.getPro-perty method, which receives as a key the name of a system property and returns its value or NULL if there is no property...

Writing MIDP Games

The Game API that came with MIDP 2.0 made mobile phone game development a thing of beauty. Although hundreds of games were written, sold and shipped on MIDP 1.0 devices, ushering in and indeed creating an exciting new industry for mobile games, it was MIDP 2.0 that elevated art into science. At the start of this chapter, we investigate some general game concepts as well as those specific to mobile phones, look at how the MIDP 2.0 Game API makes Java ME an easy choice for mobile game development...

Handling Transitions Between Foreground and Background

Since Symbian OS is a multitasking operating system, the Application Management Software AMS can move your MIDlet to the background to allow another application to execute concurrently. After a while, your MIDlet may then be sent back to the foreground. In S60 5th Edition and 3rd Edition FP2 devices, the MIDlet lifecy-cle methods are not called by default. To request the AMS to invoke MIDlet.startApp and MIDlet.pauseApp , you need to add the Nokia-MIDlet-Background-Event1 proprietary JAD...

Javalevel Debugging Support

Providing a Java ME SDK is left for Symbian OS licensees who each have their own SDK strategy. It is also the responsibility of the licensees to arrange, for example, the setup and instrumentation of the connection between the host PC and the device. The responsibility of Symbian OS is to ensure that a complete debugging solution exists for Java applications it includes debugging applications on the emulator and on target devices by performing debugging operations through a standard Java IDE....

Geotagging

Geotagging is the process of adding geographical information, which usually consists of latitude and longitude coordinates, to various forms of media, such as photographic images. The uses for geotagging can vary from finding location-based news to finding images taken near a given location by using the coordinates in a geotagging-enabled website e.g., Flickr . So let's consider an application that lets you take a picture and send it to your Flickr account, geotagged with the location in which...

Tight Integration JSR SIP

We now discuss an additional JSR integration type in which all the required functionality is fully available as a native Symbian OS service and the decision was taken to tightly integrate the JSR with this native service. Integration with native services is the obvious solution to implement. However, as we see, there are many challenges and considerations to be taken into account. We discuss such a case with reference to JSR-180 SIP. Session Initiation Protocol SIP is an application-layer...

Generic UIQ SDK

The primary role of the UIQ 3 SDK for Symbian OS is for Symbian C development. However, there are two key points that make it very relevant and useful for Java development. The UIQ 3 emulator gives full-blown Symbian OS emulation, which allows you to install, run and manage Java applications as on a real UIQ 3 device. Additionally, the UIQ 3 SDK includes a basic SDK that is compliant with the Unified Emulator Interface UEI and can be integrated with NetBeans, allowing you to develop, run and...

Multitasking of MIDlets in the Same Suite

Let's see how two MIDlets from the same suite, both running at the same time, can not only access the same classes in the JAR file but also invoke methods of objects owned by the other running MIDlet. All MIDlets from the same suite run in the same space. A new Java ME run-time process is spawned for every suite and all MIDlets from that suite run within that process and in the same Java memory space this implies that MIDlets from the same suite can communicate,programmatically. For example,...

Constraints on Heap Size

There is no predefined limit on the application heap size or on the number and stack size of Java threads. Of course, eventually you will run out of memory but you need to do something quite intense and memory consuming to get to that point. The Java Objects heap is allocated a certain size on application start up. If there is not enough memory to allocate a new object, after a few memory allocations and garbage collections, the CLDC-HI VM expands the application's Java heap to allow more...

Generic SDKs Java ME SDK and WTK

At time of going to print, we are welcoming Java ME SDK 3.0 see Figure 5.2 . Although it is too early to say farewell to the WTK, which has been the most popular SDK for quite a few years, let us meet the Java ME SDK 3.0 and go over some of its features. The Java ME SDK comes with a new underlying architecture and lots of new features such as integration with third-party emulators and devices on-device debugging ODD support WURFL-device search database Windows Mobile reference stack with ODD...

Signing a MIDlet Suite

To sign a MIDlet suite, a supplier must create a public-private key pair and sign the MIDlet JAR file with the private key. The JAR file is signed using the RSA-SHA1 algorithm. The resulting signature is encoded in Base64 format and inserted into the application descriptor as the following attribute MIDlet-Jar-RSA-SHA1 lt base64 encoding of JAR signature gt The supplier must obtain a suitable MIDlet suite code-signing certificate from an appropriate source, for example, the developer program of...

B SNAP Mobile Client API

The SNAP Mobile Client API is a lightweight library for adding connected features to Java games. It encapsulates all needed information and procedures from the server components into an easy-to-use Java API, so that you can focus on building the game logic instead of network details, matchmaking mechanisms, and so on. Although easy to use, the API is extensive and in order to understand it in full you need to study many concepts inherent to connected games. In this appendix, we use the sample...

Debug agent

Figure 5.12 DebugAgent running on device Figure 5.12 DebugAgent running on device Figure 5.13 Choosing connection method You now have a Bluetooth connection between the PC and the device. You need to set the device in the project properties see Figure 5.15 to S60Device or S60Device_over_Bluetooth if it is an older SDK . From here, you launch and debug an application exactly as on the emulator. The same progress console appears on the PC and progress on the device appears on the DebugAgent...

Retrieving Telephony Information

From S60 3rd edition FP2 onwards, there are additional system properties that provide access to telephony information. The information provided is minimal but it is meant to serve telephony services to applications that are not themselves telephony-oriented. For example, consider an application that requires locking onto a specific device. Developers have to make their applications aware of the unique IMEI of the phone and provide a mechanism to lock their applications to it. The scenario in...

Running MIDlets on the S Emulator

When you launch the MIDlet from NetBeans, the progress dialog in Figure 5.5 appears. If there is more than one MIDlet in your suite, you are asked to choose one of them see Figure 5.6 . The S60 emulator starts an application called DebugAgent whose role is to manage debug sessions. The DebugAgent display shows the launch progress see Figure 5.7 until the MIDlet becomes active and is sent to the foreground. In order to speed up the development cycle, you can keep the emulator running throughout...

Which APIs Are Supported

There is no single answer to which JSRs are supported on Symbian smartphones. The list of detected JSRs in Table 3.1 represents the family of devices to which the three reference devices belong respectively, S60 5th Edition, S60 3rd Edition FP1, and UIQ 3.0 . As you have seen, the support provided by the Nokia N95, the Nokia 5800 XpressMusic, and the Sony Ericsson W960i exceeds the list of MSA Subset Component JSRs and is nearly at the level of full MSA Component JSRs. New devices are coming...

Record Management System

MIDP provides a simple record-based persistent storage mechanism known as the Record Management System RMS . It's a package that allows the MIDlet application to store persistent data within a controlled environment, while maintaining system security. It provides a simple, non-volatile data store for MIDlets while they are not running. The classes making up the RMS are contained in the javax.microedition.rms package. Essentially, the RMS is a very small, basic database. It stores binary data in...

Eclipsing DoJa

We'd better build something or I'll lose your interest, so let's start by setting up Eclipse for DoJa development using 2.5oe. The first thing to do is to install Eclipse, if you haven't already you'll need at least version 2.1.1 . If you chose the custom installation option when installing the DoJa toolkit, you've probably also installed the Eclipse plug-in. And that's all you need to do. As an introduction to DoJa, and in the spirit of public health, we'll build a simple application for...

Why Use Java ME on Symbian OS

Why not just use Symbian C That's a good question. To answer it, we need to look firstly at what people do with their smartphones and then how it is achieved technically. mobile users 0 10 20 30 40 50 60 70 80 Figure 1.7 shows the results of a survey of how people are willing to use their smartphones. In addition, if we were to ask a random sample of people in the street what they do regularly, we'd also expect them to include activities such as playing games, sending text messages, sending...

Mean and Lean Virtual Machine

When referring to the VM, the referral is always to the headless language and core classes engine only i.e., no UI . At the time of writing this book, the majority of shipped devices include a port of Sun's CLDC-HI HotSpot VM 1.1 implementation which implements v1.1 of the CLDC specification . However, the VM is a replaceable module in the Java ME subsystem for example, in S60 3rd Edition FP2, the included VM is J9 from IBM. VM technology contains a wealth of theory and practical tricks that...

Controlling the Java Applications IAP

In Symbian OS, Internet Access Points IAP define the variable configuration factors that determine how an Internet connection is established. These factors can include the bearer e.g., CDMA, GSM or GPRS , the dial-in number, and network login names and passwords. All IAPs are stored in the native Symbian OS communication database CommsDat , which also stores the preferred order in which the IAPs should be used. On many other Java ME platforms, the underlying implementation always uses the...

Javax.microedition.amms.control.video Format Control

Figure 6.4 MobileAerith before MSA 1.1 project,5 which is a great source of advanced applications, useful tips, information on the usage ofJSRs and other help for application developers. There is also a wiki with more good information and links. All the sources and resource files for MobileAerith are available under the MobileAerith directory. You can read more and browse the source code from To get the source, you can access the MobileAerith sample from the NetBeans 6.1 Update Center see...

References

Allin, J. 2001 Wireless Java forSymbian Devices. Chichester John Wiley and Sons. Arnold, K., Gosling, J., and Holmes D. 2005 The Java Programming Language, Fourth Edition. Prentice Hall. Astle, D. and Durnil, D. 2004 OpenGL ES Game Development. Thomson. Babin, S. 2007 Developing Software for Symbian OS, Second Edition. Chichester John Wiley and Sons. Ballard, B. 2007 Designing the Mobile User Experience. Chichester John Wiley and Sons. Gamma, E., Helm, H., Johnson R., Vlissides, J. 1994 Design...

Embedded Standard Widget Toolkit

From S60 3rd Edition FP2, Nokia introduced support for the Embedded Standard Widget Toolkit eSWT which is an alternative UI toolkit to LCDUI. eSWT is a subset of the Standard Widget Toolkit SWT API, which was jointly developed by IBM and Nokia as part of the Eclipse Foundation eRCP project.5 The SWT was developed as an alternative to the AWT and Swing desktop UI toolkits included in Java SE. For example, the Eclipse IDE uses SWT for its user interface. It is very easy for SWT developers who are...

Recommended Tooling Approach for Java ME on Symbian OS

Because of the variety of available SDKs for Java ME on Symbian OS see Figure 5.1 , we start with a general discussion on which SDKs to use and when to use them. Figure 5.1 Java ME SDKs for Symbian OS We recommend that you become familiar with several of the SDKs that are covered in this chapter and use the SDK which is most appropriate according to the development stage you are at or the problem you are trying to solve. You could use the WTK, Java ME SDK 3.0 the WTK successor , Java ME SDKs...

Radio Tuner

In the previous example, we used JSR-179 and JSR-234. You could also use those Component JSRs to create a location-based radio tuner, which can discover and listen to radio stations in the current location. To discover local radio stations, we can query a remote server using JSR-172 Web Services or, as in the previous example, an alternative protocol such as REST. Again, JSR-234 AMMS provides interfaces for tuner features, such as audio radio playback and access for Radio Data System RDS...

Integration with Native Services Grf

The native Symbian OS SIP architecture is too elaborate to fully explain in the context and within the scope of this chapter. The native SIP service contains a very large number of classes, with an architecture which is considerably more complex than the generic and compact Java ME architecture it is decomposed into more than one set of APIs. This is only one of the differences that make the integration of JSR-180 SIP very challenging. The native and Java APIs are very different from one...

IAP Info API in Java ME

IAP Infi I API is a Java API. whnrn Ihn H i ilii Hlinris MIDIhIk i an access fundamental internet access point group related information. Thi3 information includoc Internet access point IAI ' related information IU. type, name Internet access point group Destination network related information ID. name, lAPs contained List of preferred Access Points Last used Access Point for TCP socket connections IAP Irifu API was iritruduuud irr S60 3rd Ediliun FP 2. The API can bo used to provide an...

Native Error Codes in Java Exception Messages

Error handling in Java ME on Symbian OS remains the same as error handling anywhere else in Java ME it is identical to standard Java error handling. The platform implementation informs you of errors through the usual mechanism of throwing Java exceptions as specified in the Java Language Specification. That does not change what changes is what appears in the error message. The thrown exception carries a description, which should provide the developer with sufficient information about the...

Push Registry

The Push Registry API allows MIDlets to be launched in response to incoming network connections. Many applications, particularly messaging applications, need to be continuously listening for incoming messages. To achieve this in the past, a Java application would have had to be continually running in the background. Although the listening Java application may itself be small, it would still require an instance of the virtual machine to be running, thus appropriating some of the mobile phone's...

Motorola MOTODEV Studio

MOTODEV Studio for Java ME see Figure 5.37 provides an Eclipse-based IDE, enhanced with EclipseME. MOTODEV Studio comes with MOTODEV SDK for Java ME, to let you access all the tools and documentation you need from one central place. MOTODEV SDK for Java ME version 1.3 supports Motorola UIQ 3 handsets, such as the MOTO Z8 and MOTO Z10 UIQ 3.1 and UIQ 3.2, respectively . The MOTODEV SDK Java ME emulator uses an emulation of the MIDlet environment in Motorola handsets and UIQ devices that is based...

MIDP Security Settings

During development, you may want be able to view and change the security settings of your tested MIDlets, for example, to see which certificates are deployed on the device. If your tested MIDlet uses the Push Registry and is in the untrusted domain, you might want to change the security settings so that it asks the user for permission only at the first launch. We now explore the security settings on Symbian smartphones through the reference devices introduced in Section 3.1. For example, on the...

Simulating Interprocess Communication

A recurrent question is whether it is possible to invoke native Symbian OS APIs, either through Java Native Interface JNI or by using another mechanism. The answer is that there is no standardized way to do so in 11 If you don't know what a SIS file is, refer to information about native development. 12 CDC-based platforms include JNI support but CDC is out of the scope of this book. CLDC in general or on Symbian OS specifically. JNI is indeed a powerful Java SE mechanism that enables desktop...