IT tutorials
 
Mobile
 

Enter Java ME on Symbian OS : Running a MIDlet on a Symbian Smartphone

1/10/2013 11:23:21 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Being able to deploy and run an application on a target Symbian smart-phone is a prerequisite for any discussion or development.

A Symbian smartphone can be built on different versions of Symbian OS, can come from different phone manufacturers, can have different form factors and different UI designs. For that reason, we choose three devices that represent the different flavors of Symbian smartphones that are currently in the market (see Figure 1). The Nokia N95 is an S60 3rd Edition device that can be operated with one hand; the Nokia 5800 XpressMusic is an S60 5th Edition device with a resistive touch screen and tactile feedback; the Sony Ericsson W960i is a UIQ 3 device with a touch screen.

Figure 1. Smartphones: a) Nokia N95, b) Nokia 5800 XpressMusic and c) Sony Ericsson W960i

Tradition says that the first application should be the canonical'Hello World' program. Since we assume that you are already familiar with MIDP development, we're going to use a new introductory application that allows us both to run our first application and to answer a question that developers ask every time they get a new device: what JSRs are supported on the device?

The first application that we run on a Symbian smartphone is a utility to detect which APIs are supported.

1. Implementing the Java ME Detectors Suite

To develop the application we need an SDK and an IDE. NetBeans and Java ME SDK 3.0 are sufficient for creating your first MIDlet. That tells you that Java ME development for Symbian OS can be done using the standard Java ME tools and SDKs that you have always used.

Create a project named 'Java ME Detectors' in NetBeans. It will contain three classes: JSRsDetectorMIDlet, JSRsView and ApiInfo (source code and binaries can be downloaded from the website for this book, developer.symbian.com/javameonsymbianos). The main functionality of the application is to receive as input the name of a JSR and a main class from that JSR, and to detect if it is supported. The input can come from the JAD, JAR manifest file, properties file, or the UI.

The Mobile Services Architecture (MSA) defines system properties for each JSR that indicate whether the JSR is supported or not. For example, wireless.messaging.version returns the WMA version supported by the device. However, to make this utility portable for devices which are not compliant with MSA, we detect the JSR by trying to load a sample class.

ApiInfo encapsulates the information that is read as input: the name of the API and its main class, which indicates that the JSR is supported if it can be dynamically loaded:

// Encapsulates an API's name and main class
public class ApiInfo {
  String name;
  String mainClass;
}

JSRsView contains the core application task, which is to detect the list of APIs given as input. When the user presses Detect, an array of ApiInfo is requested from the MIDlet and, for each ApiInfo in the array, the JSRsView.detectAPIs() method tries to load a Java class whose name is stored in the ApiInfo.mainClass member:

// The user view of the JSRs Detector MIDlet
public class JSRsView extends Form implements CommandListener {
  private Command exit = new Command("Exit", Command.EXIT, 0);
  private Command detect = new Command("Detect", Command.OK, 0);
  private JSRsDetectorMIDlet midlet;

  // CommandListener implementation
  public void commandAction(Command cmd, Displayable disp) {
    if (cmd == exit) {
      midlet.notifyDestroyed();
    } else if (cmd == detect) {
      detectAPIs();
    }
  }
  // Detect supported APIs
  private void detectAPIs() {
    resetUl();
    ApiInfo[] detectedApis = midlet.getApiInfoArray();
    for (int i = 0; i < detectedApis.length; i++) {
      try {
        Class.forName(detectedApis[i].mainClass);
        // class loaded successfully –  API is supported
        append(detectedApis[i].name + ": Yes\n");
      } catch (ClassNotFoundException cnfe) {
        // class not loaded–  API is NOT supported
        append(detectedApis[i].name + ": No\n");
      }
    }
  }
}

					  

The default input to JSRsDetectorMIDlet can be read from the JAD file by calling the MIDlet's getAppProperty() method sequentially until NULL is returned. The following JAD properties are loaded and parsed by the MIDlet to create the array of ApiInfo objects:

  • JSR1: JSR-139 CLDC 1.1, java.lang.Float

  • JSR2: JSR-118 MIDP 2.0, javax.microedition.lcdui.Custom-Item

  • JSR3: JSR-75 PIM, javax.microedition.pim.PIM

  • JSR4: JSR-75 FileConnection, javax.microedition.io.file.FileConnection

  • JSR5: JSR-82 Bluetooth, javax.bluetooth.LocalDevice

  • JSR6: JSR-135 MMAPI, javax.microedition.media.Manager

  • JSR7: JSR-172 WS, javax.xml.rpc.JAXRPCException

  • JSR8: JSR-120 WMA 1.0, javax.wireless.messaging.Mess-ageConnection

  • JSR9: JSR-177 SATSA-APDU, javax.microedition.apdu.APDUConnection

  • JSR10: JSR-177 SATSA-JCRMI, javax.microedition.jcrmi.JavaCardRMIConnection

  • JSR11: JSR-177 SATSA-PKI, javax.microedition.security-service.CMSMessageSignatureService

  • JSR12: JSR-177 SATSA-CRYPTO, javax.crypto.Cipher

  • JSR13: JSR-179 Location, javax.microedition.location.Location

  • JSR14: JSR-180 SIP, javax.microedition.sip.SipConnection

  • JSR15: JSR-184 3D, javax.microedition.m3g.Graphics3D

  • JSR16: JSR-205 WMA 2.0, javax.wireless.messaging.Size-ExceededException

  • JSR17: JSR-211 CHAPI, javax.microedition.content.ContentHandler

  • JSR18: JSR-226 SVG, javax.microedition.m2g.SVGImage

  • JSR19: JSR-229 Payment, javax.microedition.payment.TransactionModule

  • JSR20: JSR-234 AMMS, javax.microedition.amms.Global-Manager

  • JSR21: JSR-238 i18n, javax.microedition.global.ResourceManager

After downloading Java ME Detectors from the Sun Developer Network, you can build and deploy it to a device.

2. Deployment over a Short Link

Symbian OS, as an open platform, serves developer needs well and serves as an excellent open Java ME development platform even if you are developing a mobile applications for platforms other than Symbian OS.

You may deploy your suite over the air by putting it on a web server. In reality, most developers prefer a quicker and simpler mechanism so beaming the suite JAR over a short-link connection is simpler and faster. For our first deployment, we do not use a device-manufacturer tool or SDK but only the reference devices and a laptop with Blue-tooth.

After pairing the devices (Nokia N95 and Sony Ericsson W960i) with the laptop, you can send the JAR file for installation. From Windows File Explorer, go to the location of the suite binaries and drag the JAR to the appropriate file transfer service in My Bluetooth Places (see Figure 2). Alternatively, from Windows File Explorer, go to the location of the suite binaries, right click on the JAR file, and select Send to, Bluetooth. A submenu shows the paired devices and you can choose the correct device.

Figure 2. Installing a JAR through My Bluetooth Places on a Windows PC

When you send the JAR to the Nokia N95, it is stored in the Messaging Inbox (Figure 3a). When you send the JAR to the Sony Ericsson W960i, you are immediately presented with it (Figure 3b).

Figure 3. Java ME Detectors beamed to a) Nokia N95, b) Nokia 5800 XpressMusic and c) Sony Ericsson W960i

As you can see, how the device handles the suite is specific to that device. For example, the MIDlet may go into the Messaging Inbox or the Application Management System (AMS) may be automatically or manually activated. In any case, the process itself is very simple and straightforward.

To complete the installation:

  • on the Nokia N95, click all the way through until you are notified that the installation has completed

  • on the Sony Ericsson W960i, press View and click all the way through until AMS launches the application.

3. Launching Java ME Detectors

On the majority of Java-enabled feature phones, you launch a Java application from a designated menu on which all installed Java applications reside. An important feature of Symbian OS is that Java applications are executed from the main applications menu, just like native applications. In this respect, Java applications are treated as 'first-class citizens' and are no different to any native application installed or running on the device.

Now that the Java installer has completed its task, let's run JSRsDetectorMIDlet on our reference devices:

  • On the Nokia N95, click on Main menu, Applications.

  • On the Sony Ericsson W960i, from the home screen, press Menu, Tools.

Both devices present you with the main application menu from which all installed applications are launched (see Figure 4). Select the MIDlet and run it. Congratulations, you have just completed the task of running a MIDlet on a Symbian smartphone.

Figure 4. Main applications menu on a) Nokia N95, b) Nokia 5800 XpressMusic and c) Sony Ericsson W960i

Table 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.

Table 1. Supported JSRs in Reference Phones
JSRNokia N95Nokia 5800 XpressMusicSony Ericsson W960i
JSR-139 CLDC 1.1
JSR-118 MIDP 2.0/2.12.02.12.0
JSR-75 PDA Packages
JSR-82 Bluetooth and OBEX
JSR-120 WMA 1.1
JSR-135 Mobile Media API 1.1
JSR-172 Web Services 1.0
JSR-177 SATSA JCRMI, APDU, PKI, CRYPTO– – ✓✓– – ✓✓
JSR-179 Location
JSR-180 SIP
JSR-184 Mobile 3D Graphics
JSR-205 WMA 2.0
JSR-211 CHAPI
JSR-226 SVG
JSR-229 Payment
JSR-234 AMMS
JSR-238 i18n

4. Summary

This is probably not the first time you have deployed a MIDlet suite onto a real device but you can clearly see how fast and easy it is to do on a Symbian smartphone. Java ME development and deployment is easy because Symbian OS is an open platform which serves developers needs well. Later, we learn about additional ways to deploy, launch and manage Java ME applications, which will help you throughout your development.

We intentionally replaced the standard 'Hello World' program with the Java ME Detectors suite, which gives you a diagnosis tool to put into your personal development toolbox. You can always check on the web[] to see the Java specification of a device but the Java ME Detectors suite gives you an extensible tool that refers specifically to the device you are holding in your hands.

[] For Nokia, go to www.forum.nokia.com/devices.

 
Others
 
- BlackBerry Bold 9700 and 9650 Series : Fixing Problems - Updating the BlackBerry Operating System
- BlackBerry Bold 9700 and 9650 Series : Fixing Problems - Understanding Your Wireless Data Connection
- Android Application Development : The ApiDemos Application (part 2) - Adding Your Own Examples to ApiDemos
- Android Application Development : The ApiDemos Application (part 1) - Application Setup in the Manifest File, Finding the Source to an Interesting Example
- iphone Programming : Adding Missing Features (part 3) - Changing the Display Name, Enabling Rotation
- iphone Programming : Adding Missing Features (part 2) - Adding a Launch Image
- iphone Programming : Adding Missing Features (part 1) - Adding an Icon
- iphone Programming : Using Sensors - Accessing the Proximity Sensor
- Mobile Web Apps : Templating - Twitter Integration with Templating
- Mobile Web Apps : Ajax - Fetching HTML, Ajaxifying Links
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us