i325 Multi-Communication Device J2ME™ Developers’ Guide
iDEN i325 J2ME™ Developers’ Guide Table of Contents Table of Contents........................................................................................................................................ 2 Document Overview.................................................................................................................................... 6 Disclaimer ............................................................................................................................................
iDEN i325 J2ME™ Developers’ Guide 6. 7. 8. 9. 6.1. 6.2. 6.3. 6.4. 6.5. 6.6. MIDP 2.0 Record Management System (RMS) .......................................................................... 36 Overview ..................................................................................................................................... 36 Class Description ........................................................................................................................ 36 Code Examples...........
iDEN i325 J2ME™ Developers’ Guide 13.3. 13.4. 13.5. Method Descriptions ................................................................................................................... 81 Code Examples........................................................................................................................... 87 Compiling & Testing Datebook MIDlets ...................................................................................... 91 14. J2ME™ ™ Networking ............................
iDEN i325 J2ME™ Developers’ Guide 21. Customer Care API .................................................................................................................... 137 21.1. Overview ................................................................................................................................... 137 21.2. Class Description ...................................................................................................................... 137 21.3. Method Descriptions ..........
iDEN i325 J2ME™ Developers’ Guide Document Overview This guide describes the procedures used to develop a J2ME™ compliant application for the i325 multicommunication device. Also included is information on developing and packaging applications for installation as well as a step-by-step procedure for setting up a debug environment. Additionally, answers to frequently asked questions are addressed in this guide. Detailed information on the Java 2 Micro Edition environment is not provided.
iDEN i325 J2ME™ Developers’ Guide Acronyms and Definitions Acronym Terminology AMS Application Management Software API Application Programming Interface CSD GPS - Customer Specific Data DateBook DateBookEvent Global Positioning System Java Volume - Java Audio Path, Java Audio Route LWT MIDP 2.0 PKI RMS Lightweight Windowing Toolkit Mobile Information Device Profile (MIDP) v2.
iDEN i325 J2ME™ Developers’ Guide 1. Introduction Motorola’s iDEN i325 multi-communication device includes the Java 2 Platform, Micro Edition, also known as the J2ME™ platform. The J2ME™ platform enables developers to easily create a variety of applications ranging from business applications to games. Prior to its inclusion, services and applications that reside on small consumer devices like cell phones could not be upgraded or added without significant effort.
iDEN i325 J2ME™ Developers’ Guide device resources were added. These new APIs allow a Java application to leverage other capabilities of the device that are currently not accessible through standard MIDP 2.0 and CLDC APIs. Table 1.
iDEN i325 J2ME™ Developers’ Guide The i325 uses a single instance of the VM to run all three MIDlets. This means that all of the MIDlets'threads are scheduled together in a round robin fashion, but the time slices vary. The threads belonging to the foreground (active) MIDlet have the largest time slices. The threads belonging to the background (suspended) MIDlets have smaller time slices.
iDEN i325 J2ME™ Developers’ Guide Key 1 is pressed Key 1 Starts repeating Key 2 is pressed. Key 1 stops repeating Key 2 starts repeating Key 2 is Released. Key 3 is pressed Key 2 stops repeating Key 3 starts repeating Key 1 is released Key press timeline 1.4.3. Timezone and Daylight Savings Support On previous phone models no local timezone or daylight savings time information was available.
iDEN i325 J2ME™ Developers’ Guide 2. Application Management 2.1. MIDlet Lifecycle A MIDlet’s lifecycle begins once its MIDlet suite is downloaded to the device. From that point, the Application Management Software (AMS) manages the MIDlet suite and its MIDlets. The user’s primary user interface for the AMS is the Java Apps feature built into the device’s firmware. From the Java Apps feature, the user can see each MIDlet suite on the device or access the Java System menu item.
iDEN i325 J2ME™ Developers’ Guide 2.3. MIDlet Suite De-installation An installed MIDlet can be removed from the device only by de-installing it from the Java Apps menu. De-installing a MIDlet suite removes the installed image from Program Space. The resources are then removed from Data Space along with the JAD file. 2.4.
iDEN i325 J2ME™ Developers’ Guide Starting Application Constructor startApp() Paused Application Running Application pauseApp() destroyApp() notifyDestroyed() Exit Application MIDlet State Transitions Table 2. Method State Transition Methods Caller Constructor AMS startApp() AMS Purpose Initializes the MIDlet – should return quickly 1. The startApp() method is called to start the application either from a newly constructed state or from a paused state. 2.
iDEN i325 J2ME™ Developers’ Guide AMS destroyApp() 1. The destroyApp() method is called from AMS and signals the MIDlet to clean up any resources and prepare for termination. For example, open RMS records should be closed, threads should be stopped, and any other housekeeping chores should be performed. 2. The MIDlet should not call destroyApp(). notifyDestroyed() MIDlet 1. The notifyDestroyed() method is called by the MIDlet to exit and terminate itself. 2.
iDEN i325 J2ME™ Developers’ Guide Similarly to the example of losing focus immediately before the pauseApp() method is called, a MIDlet’s focus is also immediately lost immediately before its destroyApp() method is called. It’s interesting to note how an iDEN device manages the transition to the destroyed state. The user’s opportunity to exit a MIDlet using the AMS, is from the MIDlet’s Suspended screen. Typically a MIDlet is suspended, then the user exits it.
iDEN i325 J2ME™ Developers’ Guide 2.7. Java From Main Menu Previously the Java Apps menu was the only interface into the Java functionality of an iDEN device. However, starting with the i95cl, the main menu has been enhanced to allow the user to add links to MIDlets or entire MIDlet suites to the main menu. When a MIDlet is added to the main menu, the name of the individual MIDlet is used for the main menu text.
iDEN i325 J2ME™ Developers’ Guide compact Java bytecodes to native code. Using the miniJIT also increases install time of the MIDlet suite since the code analyzer and compiler execute during this time. While the miniJIT does optimize computationally intensive tasks, many common capabilities are already optimized for the iDEN platform and therefore the miniJIT provides little or no additional benefit. These capabilities include: Graphics (LCDUI) Image Processing RMS 2.9.1.
iDEN i325 J2ME™ Developers’ Guide 3. Developing, Packaging, and Deploying J2ME™ Applications 3.1. Developing – Tools and Emulation Environments In order to develop applications for a J2ME™ enabled device, a developer needs some specialized tools to improve development time and prepare the application for distribution. There are several tools available in the space, so this overview is included to help enable developers to make an informed decision on these tools. 3.1.1.
iDEN i325 J2ME™ Developers’ Guide 3.2.1. Compiling .java Files to .class Files Compiling a J2ME™ application is no different the any other J2SE™/J2EE™ application. By adding the CLDC/MIDP files (whether functional or stubbed out) to the classpath, any standard Java compiler that is JDK1.2 compliant or greater is sufficient to produce .class files suitable for the preverification step. 3.2.2. Preverifying .
iDEN i325 J2ME™ Developers’ Guide 3.2.4. JARing .class Files and Other Resources Once the application is ready to be packaged for the device, its class files and associated resources must be bundled in a Java Archive (JAR) file. The JAR file format enables a developer to bundle multiple class files and auxiliary resources into a single compressed file format. The JAR file format provides the following benefits to the developer and end-user: Portability. The file format is platform independent.
iDEN i325 J2ME™ Developers’ Guide make use of packet data services. These applications contain all the necessary data locally. Typical applications in this category include games, conversion utilities, etc. Motorola distributes two Java Application Loading tools: JAL Lite and WebJAL. Walled Garden applications can be loaded with either WebJAL or JAL Lite. Networked applications, on the other hand, can only be loaded via the WebJAL utility. Both tools are available at www.idendev.com. 3.4.
iDEN i325 J2ME™ Developers’ Guide Choose a name as well as an icon for the new connection, something like “i325”, and click on the “Ok” button. Creating a New HyperTerminal Connection Select the Communication port the data cable is connected to, typically COM1 or COM2. Setting The Connection Communication Port Page 23 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide A properties dialog box appears. Configure the bits per second to coincide with the Baud Rate set on the i325. Set the Data bits to 8, Parity to None, Stop bits to 1, and Flow control to Hardware. Setting The Communication Port Properties Once all the parameters have been set, save the profile. To save the profile, select File->Save. The profile is saved as the connection name plus an .ht extension. For the example, the profile is saved as i325.ht.
iDEN i325 J2ME™ Developers’ Guide NOTES: Java debug is turned on only for a particular HyperTerminal session. If the data cable is disconnected or ‘Disconnect’ button on the HyperTerminal is pressed, the previous sequence must be repeated to re-enable Java debug. Debug information may not appear on the HyperTerminal if extra control characters are buffered. Type “AT” in the HyperTerminal to check the connection status. If an “OK” is returned then the connection does not contain buffered characters.
iDEN i325 J2ME™ Developers’ Guide 3.4.4. Debug Statements Debugging J2ME™ applications is very similar to debugging typical Java 2 Platform applications. The most common method of debugging applications is to place System.out.println() statements in strategic locations. A simple way to create a debug and production version of the application at compile time is to encapsulate the System.out.println() statements in if…then clauses, with the if conditional checking a static Boolean variable.
iDEN i325 J2ME™ Developers’ Guide The following are additional MIDlet attributes in the I18n-ized J2ME™ platform: Table 3. I18n MIDlet Attributes For The i325 Phone Attribute Name Attribute Description iDEN-MIDlet-Name-xx The name of the MIDlet suite that identifies the MIDlets to the user in xx language. iDEN-Vendor-xx The organization that provides the MIDlet suite in xx language. iDEN-MIDlet-xx- The name, icon and class of the n MIDlet in the JAR file separated by a comma in xx language.
iDEN i325 J2ME™ Developers’ Guide 4. MIDP 2.0 LCDUI 4.1. Overview With the changes in the keypad layout and the new MIDP 2.0 UI specification, developers must consider a few implementation specifics that may affect the look and feel of the applications. Although every effort has been made to support the backward compatibility of the applications, the numerous hardware and software specification required some changes in convention from previous handsets.
iDEN i325 J2ME™ Developers’ Guide 4.3.1.2. New Implementation One of the major improvements in the UI implementation for this release is native look and feel. This encompasses not only the color palette choice, but also the font, icons, and other various design elements. With regards to commands, and in addition to the color palette matching, an outline of the soft key area is now rendered along with the text. This places hard boundaries to the areas rendered by the platform.
iDEN i325 J2ME™ Developers’ Guide 4.4.1.2. New Implementation Any platform components that occupy real estate and are added to the canvas results in a call to the sizeChanged() method, followed by a paint. Beyond adding and removing commands, addition or removal of tickers or titles invokes a call to sizeChanged(). Within the sizeChanged() callback, applications should query the new canvas size and adjust rendering accordingly.
iDEN i325 J2ME™ Developers’ Guide 4.6.1.1. Previous Implementation Items added or appended to a Form occupy a new row, regardless of the available space. This particular layout semantic provided for easy and simple implementation of platform and application. The downfall of a simple scheme becomes apparent when complex and mixed Item types are added to a Form. For example, mixing text along with images lead to large gaps of unutilized space. 4.6.1.2.
iDEN i325 J2ME™ Developers’ Guide 4.6.2.2. New Implementation Commands may be added to individual Items instead of exclusively to the Displayable. For the i325, the availability of these commands is conveyed to the user when the Item is highlighted. If a command is available to a highlighted item, the Menu icon is displayed. Pressing the Menu key brings the command submenu to the foreground. If no commands are available to a highlighted item, the Menu icon is not shown.
iDEN i325 J2ME™ Developers’ Guide MIDP 2.0 also introduces the concept of input modes for even finer control of text components. The input mode is simply a request for a specific set of characters to be entered more conveniently. Since not all devices and platforms will support all modes, no specific input modes are required by the MIDP 2.0 specification. The i325 supports several of the suggested input modes as well as some platform specific additions.
iDEN i325 J2ME™ Developers’ Guide 5. MIPD 2.0 Push Registry 5.1. Overview Push registration lets a MIDlet set itself to be launched automatically. The push registry allows for registering network and timing based activation and also manages the MIDlet activation process defined by MIDP 2.0 push registry. The i325 implementation of push registry supports all methods defined in the MIDP 2.0 PushRegistry class. 5.2.
iDEN i325 J2ME™ Developers’ Guide 5.6. Tips It’s recommended that you open the connection immediately in a separate thread in the MIDlet’s startApp() and read the received message. Applications should not use any reserved ports as defined by IANA, for example FTP, Telnet, or HTTP. Page 35 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 6. MIDP 2.0 Record Management System (RMS) 6.1. Overview The most common mechanism for persistently storing data on a MIDP device is through RMS. RMS lets a MIDlet store variable length records on the device. Those records are accessible to any MIDlet in the MIDlet suite, and also to MIDlets outside of the MIDlet suite if permission is given when the record is created. The RMS implementation on the i325 phone is MIDP 2.0 compliant.
iDEN i325 J2ME™ Developers’ Guide The following simple code example will open (and possibly create) a record store that can be shared with other MIDlet suites. The record store is owned by the current MIDlet suite. The authorization mode is set when the record store is created, as follows: AUTHMODE_PRIVATE allows only the MIDlet suite that created the record store to access it. This case behaves identically to openRecordStore(recordStoreName, createIfNecessary).
iDEN i325 J2ME™ Developers’ Guide 7. MIDP 2.0 File I/O and Secure File I/O 7.1. Overview The objective of the File I/O and secure File I/O API is to provide a generic platform for the Java developer to use to open, read, write, append and delete a file sequentially. The goal is to provide UNIX like file access APIs, as a simple alternative to Record Management System (RMS). This lets MIDlets save information between invocations; this is called “persistent storage.
iDEN i325 J2ME™ Developers’ Guide You can also delete a file with the DELETE keyword. Note that all the InputStreams, OutputStreams and StreamConnections associated with a file should be closed before deleting the file. If a file cannot be deleted, these methods throw an IOException. Here are some examples of name parameters that delete a file: • "file://temp.txt;DELETE" deletes temp.txt. • "sfile://temp.txt;PASSWORD=313;DELETE" deletes the secure file temp.txt with the password 313.
iDEN i325 J2ME™ Developers’ Guide // write the bytes os.write(b.getBytes()); int dataAvailable = is.available(); byte [] b1 = new byte[dataAvailable]; // read the bytes is.read(b1); } finally { if (sc != null) sc.close(); if (is != null) is.close(); if (os != null) os.close(); } 7.4.2. Example # 2 (Complete File MIDlet Code) The following example is a simple MIDlet that will provide the overall operation of the file I/O interface and how most of the API’s can be used.
iDEN i325 J2ME™ Developers’ Guide /** * The list of tests */ List myList; /** * Ok command to indicate a test was selected */ Command okCommand; /** * Create NetTests */ public Example2( ) { } /** * Start running */ protected void startApp() { myDisplay = Display.getDisplay(this); myOutput = new Form("Results"); myList = new List("Select test:", List.IMPLICIT, testList, null); okCommand = new Command("OK", Command.OK, 1); myOutput.addCommand(okCommand); myList.addCommand(okCommand); myOutput.
iDEN i325 J2ME™ Developers’ Guide /** * Handle ok command */ public void commandAction(Command c, Displayable s) { if (((s == tf1) || (s == tf2)) && (c == okCommand)) { if(s==tf1) fileURL = tf1.getString(); if(s==tf2) { /* data in the string form */ stringNum = tf2.getString(); /* convert the string into the integer form */ dataNum = stringNum.length(); } } if (s == myList) { switch (((List)s).getSelectedIndex()) { case 0: myDisplay.setCurrent(myOutput); setFileName(); break; case 1: myDisplay.
iDEN i325 J2ME™ Developers’ Guide //get OutputStream os = sc.openOutputStream(); //get InputStream is = sc.openInputStream(); //write the bytes to the file os.write(message); myOutput.append("write/append done"); //create an array to store available data // from the file byte [ ] b1 = new byte[is.available()]; //read the bytes is.read(b1); String readString = new String(b1); //printout the data in the phone screen myOutput.append(readString); myOutput.
iDEN i325 J2ME™ Developers’ Guide //close the stream if (sc != null) sc.close(); myOutput.append("file deleted"); } catch (Exception ex1 ) { System.out.println("Exception: " + ex1.getMessage()); try { if (sc != null) sc.close(); } catch(Exception ex) { } } } } 7.4.3. Example # 4 (Complete Secure File MIDlet Code) The following example is a simple MIDlet that provides the overall operation of the secure file I/O interface and how most of the API’s can be used.
iDEN i325 J2ME™ Developers’ Guide /** * The list of tests */ List myList; /** * Ok command to indicate a test was selected */ Command okCommand; /** * Create NetTests */ public Example4( ) { } /** * Start running */ protected void startApp() { myDisplay = Display.getDisplay(this); myOutput = new Form("Results"); myList = new List("Select test:", List.IMPLICIT, testList, null); okCommand = new Command("OK", Command.OK, 1); myOutput.addCommand(okCommand); myList.addCommand(okCommand); myOutput.
iDEN i325 J2ME™ Developers’ Guide /** * Handle ok command */ public void commandAction(Command c, Displayable s) { if (((s == tf1) || (s == tf2)) && (c == okCommand)) { if(s==tf1) fileURL = tf1.getString(); if(s==tf2) { /* data in the string form */ stringNum = tf2.getString(); /* convert the string into the integer form */ dataNum = stringNum.length(); } } if (s == myList) { switch (((List)s).getSelectedIndex()) { case 0: myDisplay.setCurrent(myOutput); setFileName(); break; case 1: myDisplay.
iDEN i325 J2ME™ Developers’ Guide //get InputStream is = sc.openInputStream(); //write the bytes to the file os.write(message); myOutput.append("write/append done"); //create an array to store available data from the file byte [ ] b1 = new byte[is.available()]; //read the bytes is.read(b1); String readString = new String(b1); //printout the data in the phone screen myOutput.append(readString); myOutput.append("read finished"); //close all the opened streams if (is != null) is.close(); if (os != null) os.
iDEN i325 J2ME™ Developers’ Guide try { if (sc != null) sc.close(); } catch(Exception ex) { } } } } 7.5. Tips Like RMS, it is much faster to read and write in big chunks than it is to do so in small chunks. The optimal size for reading and writing is 512 bytes. File I/O is a simple alternative to Record Management System (RMS). When used effectively, direct file I/O can speed up storing and retrieving data.
iDEN i325 J2ME™ Developers’ Guide In the InputStream method mark(), the readlimit argument tells the input stream to allow that many bytes to be read before the mark position gets invalidated. Since this operation is on a file, “remembering” the entire contents of stream/file does not incur any type of cost, so the readlimit parameter is ignored, preventing mark position invalidation. A secure file can only be opened with the correct password.
iDEN i325 J2ME™ Developers’ Guide 8. MIDP 2.0 Security API 8.1. Overview The MIDP 2.0 Security API consists of HttpsConnection, SecureConnection, SecurityInfo, Certificate and CertificateExecption. The HttpsConnection class defines the necessary methods and constants to establish a secure network connection. The URL that specifies HTTPS when passed to Connector.open will return an HttpsConnection. The SecureConnection class defines the secure socket stream connection.
iDEN i325 J2ME™ Developers’ Guide 8.4. Code Examples 8.4.1. HttpsConnection The following is the code example of HttpsConnection: open a HTTPS connection, set its parameters, then read the HTTP response. void getViaHttpsConnection (String url) throws CertificateException, IOException { HttpsConnection c = null; InputStream is = null; try { c = (HttpsConnection) Connector.
iDEN i325 J2ME™ Developers’ Guide 8.4.2. SecureConnection The following examples show how a SecureConnection would be used to access a sample loopback program. SecureConnection sc = (SecureConnection) Connector.open("ssl://host.com:79"); SecurityInfo info = sc.getSecurityInfo(); boolean isTLS = (info.getProtocolName().equals("TLS")); sc.setSocketOption(SocketConnection.LINGER, 5); InputStream is = sc.openInputStream(); OutputStream os = sc.openOutputStream(); os.write("\r\n".
iDEN i325 J2ME™ Developers’ Guide 8.4.5. CertificateExecption try { c = (HttpsConnection)Connector.open("https://www.bellsouth.com/", Connector.READ_WRITE, true); is = c.openInputStream(); . . . . . } catch (CertificateException ce) { System.out.println ("Unexpected CertificateException } 8.5. " + ce); Tips • HTTPS is the secure version of HTTP (IETF RFC2616), a request-response protocol in which the parameters of the request must be set before the request is sent.
iDEN i325 J2ME™ Developers’ Guide 9. MIDP 2.0 Platform Request 9.1. Overview The Platform Request API allows a Java application to pass a URL to the phone to have it handled by one of the phone’s native applications. The i325 Platform Request API supports only one type of URL: initiating a telephone call. 9.2. Class Description The Platform Request API is located in package javax.microedition.midlet java.lang.Object | + - javax.microedition.midlet.MIDlet 9.2.1. Method Description 9.2.1.1.
iDEN i325 J2ME™ Developers’ Guide public void pauseApp() { } public void destroyApp(Boolean unconditional) { } public void commandAction(Command c, Displayable s) { if (s == myList) { try { switch (((List)s).getSelectedIndex()) { case 0: platformRequest("call:5552313"); break; case 1: platformRequest("tel:5552312;postd=10101010"); break; case 2: platformRequest(""); break; case 3: platformRequest("this is an invalid URL"); break; } } catch(Exception e) { } } } } 9.4.
iDEN i325 J2ME™ Developers’ Guide 10. Interconnect/Phone Call Initiation API 10.1. Overview The Call Initiation API provides the ability to request an Interconnect service call. The API supports international and domestic phone numbers, “pause” dialing, and “wait” dialing. The API does not actually make the call. Instead, it is designed to simply initiate a call request, wherefore then the end user must grant the request by pressing the Send key (also known as the Fire key in the Canvas Class).
iDEN i325 J2ME™ Developers’ Guide Table 4. Prefix Tag "phon" or "PHON" none* *If the argument does not contain a tag, the request will be consider as an interconnect call.
iDEN i325 J2ME™ Developers’ Guide Return values of the makeCall() method are: • GenericCall.CALL_RESPONSE_OK if phone call request is placed successfully (user must grant the request) • GenericCall.CALL_RESPONSE_FAILURE if request fails because the unit is not idle (e.g. in an active service call such as a private call) • GenericCall.
iDEN i325 J2ME™ Developers’ Guide If the device is busy in another call, makeCall(955555555) displays the following: Requesting to call to 955555555 CALL_RESPONSE_FAILURE Page 59 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide Page 60 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 11. RecentCalls API 11.1. Overview The RecentCalls API lets you access the phone’s recent calls data. It lets you read and remove recent call entries. However, it does not let you add to the recent calls list. 11.2. Class Descriptions The API for the RecentCalls is located in package com.motorola.iden.recentcalls Following is the class Hierarchy of RecentCalls API. java.lang.Object | + - com.motorola.iden.recentcalls.RecentCalls | + - com.motorola.iden.recentcalls.
iDEN i325 J2ME™ Developers’ Guide 11.3.1.3. lastEntry Returns the last RecentCallsEntry if the RecentCalls list is not empty, null if the list is empty. public RecentCallsEntry lastEntry() Be sure to call refreshList() before using this function, to ensure that the RecentCalls list is up-to-date. If this application does not have the right permissions to read the native recent calls list, this method throws a SecurityException 11.3.1.4.
iDEN i325 J2ME™ Developers’ Guide 11.3.1.8. currentUsage Returns the number of RecentCallsEntries in this RecentCalls list. public int currentUsage() Be sure to call refreshList() before using this function, to ensure that the RecentCalls list is up-to-date. If this application does not have the right permissions to read the native recent calls list, this method throws a SecurityException 11.3.1.9. isListEmpty Returns true if this RecentCalls list contains no entries; false, otherwise.
iDEN i325 J2ME™ Developers’ Guide If this application does not have the right permissions to read the native recent calls list, this method throws a SecurityException 11.3.1.13. removeEntryAt Deletes the RecentCallsEntry at the specified index from this RecentCalls list. public boolean removeEntryAt(int entryNumber) throws IllegalArgumentException This method returns true if the operation is successful, false otherwise. If the operation fails, check to see if the entry is still there and try again.
iDEN i325 J2ME™ Developers’ Guide 11.3.2.2. getCallType Returns the call type for this RecentCallsEntry. public int getCallType() If the service call type for this RecentCallsEntry is JAVA_SERVICE_CALL_TYPE_PHONE, this method returns JAVA_CALL_TYPE_INCOMING, JAVA_CALL_TYPE_OUTGOING, or JAVA_CALL_TYPE_MISSED. Otherwise, this method returns CALL_TYPE_NO_STATUS. 11.3.2.3. getPhoneNumber Returns the phone number for this RecentCallsEntry. public String getPhoneNumber() 11.3.2.4.
iDEN i325 J2ME™ Developers’ Guide 11.4. Code Examples The following is the code example of RecentCalls API RecentCalls RCL =new RecentCalls(); RecentCallsEntry myEntry = new RecentCallsEntry; if(RCL.isListEmpty()){ System.out.println("This Recent Calls List is empty"); } else { try { if(RCL.refreshList()){ try { int currentUsage = RCL.currentUsage(); } catch(Exception e) { System.out.println( "Exception thrown in currentUsage()" + e); } try { for(int i = 0; i < currentUsage; i++){ myEntry = RCL.
iDEN i325 J2ME™ Developers’ Guide try { myEntry = RCL.firstEntry(); System.out.println("Phone number for first Entry is " + myEntry.getPhoneNumber()); System.out.println("Call Type for first Entry is " + myEntry.getCallType()); System.out.println( "Service Call Type for first Entry is " + myEntry.getServiceCallType()); System.out.println( "The time of the call for first Entry is " + myEntry.getHour() + ":" + myEntry.getMinute()); System.out.println( "The date of the call for first Entry is " + myEntry.
iDEN i325 J2ME™ Developers’ Guide } try { System.out.println("The number of outgoing calls are " + RCL.numOutgoingCalls()); }catch(Exception e){ System.out.println( "Exception thrown in numOutgoingCalls() " + e); } try { System.out.println("The number of missed calls are " + RCL.numMissedCalls()); } catch(Exception e) { System.out.println( "Exception thrown in numMissedCalls() " + e); } try { for(int i = 0; i < 5 ; i++){ RCL.removeEntryAt(i); } } catch(Exception e) { System.out.
iDEN i325 J2ME™ Developers’ Guide 12. PhoneBook 12.1. Overview The Java-based PhoneBook APIs let you access the user' s phonebook data that’s stored in the native database. The methods support such functionality as opening a phonebook, reading phonebook entries, creation a phonebook entry, importing a phonebook entry, removing specified phonebook entries, deleting all phonebook entries, determining available storage and so on. 12.2.
iDEN i325 J2ME™ Developers’ Guide public static PhoneBook openPhoneBook(int mode, int sort) throws UDMException This method returns a PhoneBook with the phone’s phonebook entries, sorted either by name or speed dial number. mode must be either READ_ONLY or READ_WRITE. Sort must be either NAME_SORT or SPEED_NUM_SORT. Otherwise, this method throws an IllegalArgumentException. Note that if you sort by speed dial number, you may not be able to retrieve entries without a speed dial number.
iDEN i325 J2ME™ Developers’ Guide If the SIM card type is GSM SIM or ENDEAVOR SIM and reverseOrder is true, this method throws a UDMException with the string "PhoneBook don' t support reverse order". 12.3.2.4. getFieldDataType Returns the data type for the given field ID public int getFieldDataType(int fieldID) throws UDMException Use this method to find the data types for field IDs that may have different types of data in each element.
iDEN i325 J2ME™ Developers’ Guide 12.3.2.8. setString Sets the value of the specified string field. public void setString(int fieldID, String value) throws UDMException If fieldID is not FORMATTED_NAME, GRP, IP or EMAIL, this method throws a UDMException with the string "Not supported field ID". Keep these pointers in mind when you set the value: • The valid values for the FORMATTED_NAME field depend on the phone’s SIM type.
iDEN i325 J2ME™ Developers’ Guide 12.3.2.11. setTypedString Sets the value of the specified typed string field public void setTypedString(int fieldID, int typeID, String value) throws UDMException If fieldID is not TEL, SPEED_NUM, or PRIV, this method throws a UDMException with the string "Not supported field ID". If typeID is not a type supported by the field, this method throws a UDMException. A list of fields and their supported types is at the PhoneBook method getSupportedTypes().
iDEN i325 J2ME™ Developers’ Guide PhoneBookEntry.IP If SIM Type is SIM_CONDOR or SIM_FALCON, it’s supported. Otherwise, it’s not supported. PhoneBookEntry.EMAIL, PhoneBookEntry.RINGER If SIM Type is SIM_FALCON, they’re supported. Otherwise, they’re not supported. PhoneBookEntry.HUB 12.3.3.3. isCurrent Returns true if a PhoneBookEntry object has been created since the last native phonebook update. public static boolean isCurrent() 12.3.3.4.
iDEN i325 J2ME™ Developers’ Guide 12.3.3.5. removePhoneBookEntry Removes the specified PhoneBookEntry from the PhoneBook. public void removePhoneBookEntry(PhoneBookEntry element) throws UDMException If the PhoneBookEntry is not in this PhoneBook, this method throws a UDMException with “PhoneBookEntry is not in PhoneBook”. If you opened the PhoneBook in read-only mode, this method throws a UDMException with the string "PhoneBook is Read only".
iDEN i325 J2ME™ Developers’ Guide 12.4. Code Examples The following is the code example of PhoneBook: /** * Demo program of Motorola iDEN SDK PhoneBook APIs * Filename: MyPhoneBook.java *
*
* MOTOROLA and the Stylized M Logo are registered trademarks of * Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
* © Copyright 2003 Motorola, Inc. All Rights Reserved. *
* * @version iDEN Phonebook demo 1.0 * @author Motorola, Inc. */ import import import import import com.motorola.iden.iDEN i325 J2ME™ Developers’ Guide for (int j= 0; j
iDEN i325 J2ME™ Developers’ Guide public MyPhoneBook() { textform = new Form("Hello, PhoneBook!"); exitCommand = new Command("exit", Command.EXIT, 2); checkCommand = new Command("check", Command.OK, 1); textform.addCommand(exitCommand); textform.addCommand(checkCommand); textform.setCommandListener(this); int[] type; Enumeration v; String title; try { /* Creates a PhoneBook by read and write mode */ contacts = UDM.openPhoneBook(UDM.
iDEN i325 J2ME™ Developers’ Guide contact.setString(PhoneBookEntry.EMAIL, "someone@somesite.com"); contact.setString(PhoneBookEntry.IP, "127.0.0.1"); contact.setInt(PhoneBookEntry.RINGER, 2); contact.setTypedString(PhoneBookEntry.TEL, PhoneBookEntry.TYPE_WORK_1, "1234567"); contact.commit(); Thread.sleep(200); slots = contacts.getAvailableStorage(); for (int i= 0; i < slots.length; i++) { System.out.println(slots[i]); } } catch (Exception ex) { ex.printStackTrace(); } } public void startApp() { Display.
iDEN i325 J2ME™ Developers’ Guide 12.5. Compiling & Testing PhoneBook MIDlets • Method PhoneBook.isCurrent() always returns true since there is no native support for this method. • Method PhoneBook.getAvailableStorage()always returns an empty array since there is no native support for this method. • Method PhoneBookEntry.getAvailSpeedNum()always returns 1 since there is no native support for this method. Page 80 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 13. DateBook 13.1. Overview Java-based DateBook APIs provide methods to access the user' s datebook data stored within the native database.
iDEN i325 J2ME™ Developers’ Guide To determine whether your application has modified a DateBookEvent without committing the change (with DateBookEvent.commit())., use DateBookEvent.isModified(). To determine whether the phone’s native datebook database has been changed since the DateBook was created, use DateBook.isCurrent(). 13.3.2. DateBookEvent Methods 13.3.2.1. commit Writes the data in the DateBookEvent to the phone’s native datebook.
iDEN i325 J2ME™ Developers’ Guide Keep the following pointers in mind when setting these values: • The phone’s native datebook contains only events that occur between a month in the past and a year in the future. If you try to set the START or END fields to a value outside those bounds, this method throws an IllegalArgumentException with either the string “invalid start time” or “invalid end time.” • The event’s START field must earlier than its END field.
iDEN i325 J2ME™ Developers’ Guide Keep the following pointers in mind when setting these values: • The SUMMARY and LOCATION fields can contain a maximum of 64 characters if the strings have no Unicode characters, or a maximum of 32 characters if the strings do have Unicode characters. • The MIDLET_SUITE and MIDLET fields let you specify a MIDlet that is launched when this event times out. Always set the MIDLET_SUITE field before setting the MIDLET field.
iDEN i325 J2ME™ Developers’ Guide 13.3.3.1. addExceptDate Adds a date to the repeat pattern’s list of dates on which the event will not occur. public void addExceptDate(long date) The date should greater than date offset in milliseconds from January 1, 1970, to January 1, 1999, that means date should greater than 915148800000L. Otherwise, this method throws an IllegalArgumentException. 13.3.3.2. removeExceptDate Removes a date from the repeat pattern’s list of dates on which the event will not occur.
iDEN i325 J2ME™ Developers’ Guide The phone’s native datebook contains only events that occur between a month in the past and a year in the future. If you try to set the END field to a value outside those bounds, this method throws an IllegalArgumentException 13.3.4. DateBook Methods 13.3.4.1. createDateBookEvent Creates a DateBookEvent for this DateBook.
iDEN i325 J2ME™ Developers’ Guide Note that the phone’s native datebook contains only events that occur between a month in the past and a year in the future. If the startDate or endDate don’t fall within those bounds, this method throws an IllegalArgumentException. 13.3.4.6. getEventCount Returns an integer array of the number of used and empty slots in the native datebook database. public int[] getEventCount() throws UDMException Each non-repeat event occupies 1 slot.
iDEN i325 J2ME™ Developers’ Guide public MyDateBook() { textform = new Form("Hello, DateBook!"); exitCommand = new Command("exit", Command.EXIT, 2); checkCommand = new Command("check", Command.OK, 1); textform.addCommand(exitCommand); textform.addCommand(checkCommand); textform.setCommandListener(this); try { /* Create a datebook with read and write mode. */ calendars = UDM.openDateBook(UDM.READ_WRITE); if (calendars != null) { /* Get number of entries in DateBook. */ int no = calendars.
iDEN i325 J2ME™ Developers’ Guide /* Get how often and when this event occurs. */ DateBookRepeatEvent rpevent = dateEvent.getRepeat(); if (rpevent != null) { int data = rpevent.getInt( DateBookRepeatEvent.FREQUENCY); System.out.println("FREQUENCY " + Integer.toString(data, 16) ); data = rpevent.getInt( DateBookRepeatEvent.MONTH_IN_YEAR); System.out.println("MONTH_IN_YEAR " + Integer.toString(data, 16) ); data = rpevent.getInt( DateBookRepeatEvent.WEEK_IN_MONTH); System.out.
iDEN i325 J2ME™ Developers’ Guide /* Create one event */ System.out.println("Current phone time is "+ System.currentTimeMillis()); long currentTime = 0; dateEvent = calendars.createDateBookEvent(); dateEvent.setString(DateBookEvent.SUMMARY, "Non-Repeat Event"); currentTime = System.currentTimeMillis()+ 60*60000; dateEvent.setDate(DateBookEvent.START, currentTime); dateEvent.setDate(DateBookEvent.END, currentTime + 600000); /* Associate a midlet_suite_name and a midlet_name * with this event */ dateEvent.
iDEN i325 J2ME™ Developers’ Guide 13.5. Compiling & Testing Datebook MIDlets • Method DateBook.getEventCount() always returns an empty array since there is no native support for this method. • Method DateBook.isCurrent() always returns true since there is no native support for this method. • Method DateBook.entryIsModified(PhoneBookEntry entry) always returns false since there is no native support for this method Page 91 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 14. J2ME™ ™ Networking 14.1. Overview The i325 phone provides the following protocols specified in MIDP 2.0: • HTTP • HTTPS • TCP Sockets • SSL Secure Sockets • Server Sockets • UDP Sockets • Serial Port Access 14.2. Timeouts The timeout period for the TCP implementation on the i325 phone is 40 seconds for an open operation.
iDEN i325 J2ME™ Developers’ Guide 14.3. Protocols 14.3.1. HTTP The HTTP implementation follows the MIDP 2.0 standard. The Connector.open() methods return an HttpConnection object that is then used to open streams for reading and writing. The following is a code example: HttpConnection hc = (HttpConnection)Connector.open("http://www.motorola.
iDEN i325 J2ME™ Developers’ Guide Although similar to HTTP, notice the required port number at the end of the remote address. In the previous protocols, those ports are well known and registered so they are not required, but in the case of low level sockets, this value is not defined. The port number is a required parameter for this protocol stack. 14.3.4.
iDEN i325 J2ME™ Developers’ Guide 14.3.7. Serial Port Access Applications using the bottom connector (serial port) to communicate with a variety of devices are given exclusive access to the port until either the application voluntarily releases the port or the application is terminated. Much like any other networking connection, opening a serial port is not guaranteed and an exception may be thrown.
iDEN i325 J2ME™ Developers’ Guide And here are the new parameters: Table 7. Parameter baudrate bitsperchar stopbits parity blocking autocts autorts New Connection Optional Parameters Default platform dependent 8 1 None On On On Description The speed of the port. The number bits per character(7 or 8). The number of stop bits per char(1 or 2) The parity can be odd, even, or none. If on, wait for a full buffer when reading. If on, wait for the CTS line to be on before writing.
iDEN i325 J2ME™ Developers’ Guide • The InputStream and OutputStream as well as the Connection object need to be completely closed. • An application in the suspended state can still continue to actively use the networking facilities of the i325 phone. • The platform does not support simultaneous voice and data transmissions. Page 97 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide Page 98 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 15. Location API 15.1. Overview The i325 phone lets users and developers access GPS position information such as latitude, longitude, altitude, speed, and so on. This feature is provided as a built-in application in the phone’s standard ergonomics and as a J2ME™ API developers can use to create custom AGPS-based applications. This section describes some of the phone’s features that affect AGPS accuracy and availability from a J2ME™ MIDlet.
iDEN i325 J2ME™ Developers’ Guide position with all the attributes set to UNAVAILABLE and with the PositionConnection’s status code set to POSITION_RESPONSE_RESTRICTED. After selecting one of the permission options, the user needs to resume the application. After permission is granted, the Java API brings up a system screen to prompt the user if the Almanac data in the phone is out of date or invalid, and the phone is not provisioned for packet data service.
iDEN i325 J2ME™ Developers’ Guide • delay=high This option provides a response to the application where delay is longer than a delay=low setting. It provides for an assisted or autonomous fix for the application. The phone uses existing assist data only if it is available and valid; otherwise, the location fix shall proceed autonomously. Currently, maximum response time for this type of request is 180 seconds. If the response times out, position will be returned with the appropriate status and error code.
iDEN i325 J2ME™ Developers’ Guide 15.3.1.2. requestPending Returns true if there is a pending position request. public boolean requestPending() Call this method on a connection before making a new request from another thread. 15.3.1.3. getStatus Returns the status for the last getPosition() call. public int getStatus() Call this method only after calling getPosition(). Use the position obtained only if getStatus() returns POSITION_RESPONSE_OK.
iDEN i325 J2ME™ Developers’ Guide • PositionDevice.GPGSV3 • PositionDevice.GPRMC • PositionDevice.GPVTG If the message type is other than above, this method throws an IllegalArgumentException. If the method cannot fulfill the request for an NMEA sentence, this method returns a null string. This first time you call this message, it turns on the GPS chip for NMEA messages. It’s the application’s responsibility to stop the NMEA request once it is done using it, 15.3.1.5.
iDEN i325 J2ME™ Developers’ Guide The following table shows the possible combinations of response codes for these two methods: PositionConnection Status Values Response Codes POSITION_RESPONSE_OK POSITION_OK ACCURACY_NOT_ATTAINABLE ACC_NOT_ATTAIN_ASSIST_DATA_UNAV FIX_NOT_ATTAINABLE FIX_NOT_ATTAIN_ASSIST_DATA_UNAV BATTERY_TOO_LOW GPS_CHIPSET_MALFUNCTION ALMANAC_OUT_OF_DATE, UNAVAILABLE POSITION_RESPONSE_ERROR 15.3.2.2. getAssistanceUsed Checks if a fix has been retrieved using assistance.
iDEN i325 J2ME™ Developers’ Guide if (oap != null ) { if(c.getStatus() == PositionConnection.POSITION_RESPONSE_OK) { // Good position // Check for any error from device on position // Application needs to check for null position if(oap.getResponseCode() == PositionDevice.POSITION_OK) { // no error in the position if(oap.hasLatLon()) { // int value of Latitude and Longitude of the position in // arc minutes multiplied by 100,000 to maintain accuracy // or UNAVAILABLE if not available int lat = oap.
iDEN i325 J2ME™ Developers’ Guide else if(oap.getResponseCode() == PositionDevice.FIX_NOT_ATTAIN_ASSIST_DATA_UNAV) { // means position information not provided (timeout) and // assistant data unavailable } else if(oap.getResponseCode() == PositionDevice.BATTERY_TOO_LOW) { // means battery is too low to provide fix } else if(oap.getResponseCode() == PositionDevice.GPS_CHIPSET_MALFUNCTION) { // means GPS chipset malfunction } else if(oap.getResponseCode() == PositionDevice.
iDEN i325 J2ME™ Developers’ Guide The following is an NMEA code example: try { PositionConnection posCon = (PositionConnection)Connector.open("mposition:delay=low"); String temp1 = posCon.getNMEASentence(PositionDevice.GPGGA); if(posCon.getStatus() == POSITION_RESPONSE_OK) { if(temp1 != null && temp1.equals("")) { // valid GPGGA string, parse it to extract // the required information } else if(posCon.
iDEN i325 J2ME™ Developers’ Guide requesting a new fix. After this pause, the application can continue requesting fixes at its normal frequency. • GPS subsystem requires about one second to calculate a new fix, so any request for a new fix during this one-second period may result in the exact same position information including the time stamp. Therefore it is recommended that an application request a new position no more than once per second.
iDEN i325 J2ME™ Developers’ Guide 16. Crypto APIs 16.1. Overview To complement SSL/TLS/HTTPS and enrich secure Java applications, the i325 phone includes a set of lightweight cryptography APIs that provide flexible and customizable end-to-end application-layer security in the J2ME™ environment. A rich variety of cryptographic mechanisms and algorithms are incorporated into these APIs, thus providing confidentiality, integrity and authentication.
iDEN i325 J2ME™ Developers’ Guide This class provides the functionality of a cryptographic cipher for encryption and decryption 16.2.3. Signature Description A digital signature is simply a message digest that has been processed with a signer’s private key. The signature can be passed around with the data, providing proof that whoever signed the data had access to the private key. The Signature class provides the functionality of signing and verifying a digital signature. 16.2.4.
iDEN i325 J2ME™ Developers’ Guide 16.3.1.2. update Updates the digest with the specified bytes. public void update(byte[] input, int offset, int len) This method updates the message digest with an array of bytes that represents one of several parts of a single message. A message can be submitted in separate blocks. This method can be called multiple times. input is the array of bytes. offset is the offset to start from in the array of bytes. len is the number of bytes to use. 16.3.1.3.
iDEN i325 J2ME™ Developers’ Guide opmode is the operation mode of this cipher (e.g. ENCRYPT_MODE, DECRYPT_MODE). key is the encryption key. params is the algorithm parameters. 16.3.2.3. update Updates the cipher with the specified bytes. public final byte[] update(byte[] input, int offset, int len) throws IllegalStateException This method places information into the cipher to start or to continue a multiple-part encryption or decryption operation.. input is the input buffer.
iDEN i325 J2ME™ Developers’ Guide 16.3.3.4. update Updates the data to be signed or verified with the specified bytes. public final void update(byte[] data, int offset, int len) throws SignatureException This method updates the data to be signed or verified with the specified array of bytes. data is the array of bytes. offset is the offset to start from in the array of bytes. len is the number of bytes to use, starting at offset. 16.3.3.5.
iDEN i325 J2ME™ Developers’ Guide 16.3.4.3. doPhase Updates the KeyAgreement with a key received from one of the other parties involved in this key agreement. public final Key doPhase(Key key, boolean lastPhase) throws InvalidKeyException key is the key for this phase. For example, in the case of Diffie-Hellman between two parties, this would be the other party' s Diffie-Hellman public key. lastPhase is a Boolean flag that indicates whether this is the last phase of this key agreement.
iDEN i325 J2ME™ Developers’ Guide 16.4.2. MessageDigest Example #2 public CDemo2() { byte[] message1 = new byte[25]; byte[] message2 = new byte[250]; byte[] digest; try{ //get an Instance of MessageDigest whose algorithm //is SHA-1 MessageDigest sha = MessageDigest.getInstance("SHA"); //update message1 into MessageDigest context sha.update(message1,0,25); //update part of message2 (start at element 2, length //125) // into MessageDigest context sha.
iDEN i325 J2ME™ Developers’ Guide //init cipher A A.init(Cipher.ENCRYPT_MODE, key); //get generated IV iv = A.getIV(); //encrypt cipher = A.doFinal(info.getBytes()); //new IvParameterSpec for decryption IvParameterSpec ips = new IvParameterSpec(iv); //init cipher for decryption B.init(Cipher.DECRYPT_MODE,key,(AlgorithmParameterSpec)ips); //decrypt the message byte out[] = B.doFinal(encrypted3); //get the decrypted info output = new String(out, 0, out.length); } catch (Exception e) { } } 16.4.4.
iDEN i325 J2ME™ Developers’ Guide //set ECDSAParameterSpec for verifying //setup both curve and r-value verify.setParameter(ecdsaparameter); //initialize for verifying verify.initVerify((ECC_PublicKey)publickey); //update the message to be verified verify.update("testtesttest".getBytes(),0,12); //verify boolean b = sig2.verify(signature); } catch (Exception e){ } } 16.4.5.
iDEN i325 J2ME™ Developers’ Guide //gen keypair keypair = dhgen.generateKeyPair(); //get publickey and privatekey for dh publickey = keypair.getPublic(); privatekey = keypair.getPrivate(); //Alice //create dhspec dhspec2 = new DHParameterSpec(p,g,q); //create dhgen dhgen2 = KeyPairGenerator.getInstance("DH"); //init dhgen dhgen2.initialize(dhspec2); //gen keypair keypair2 = dhgen2.generateKeyPair(); //get publickey and privatekey for dh publickey2 = keypair2.getPublic(); privatekey2 = keypair2.
iDEN i325 J2ME™ Developers’ Guide 16.5. Tips • In order to use DES, DESede, AES, and ARC4, a MIDlet must implement the Key interface. • DES supports 56-bit key (8 bytes, including parity). DES key parity check and weak key detection are not supported. • DESede, also called 3DES (“triple DES”), supports 168-bit keys (24 bytes, including parity). Parity check and weak key detection are not supported. • AES supports 128, 192 or 256-byte key.
iDEN i325 J2ME™ Developers’ Guide Page 120 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 17. Look and Feel (LnF) 17.1. Overview The main purpose of the LnF API is to provide facilities to modify the graphical user interface and interface related behavior of J2ME™ LCDUI components without breaking backward compatibility and without modifying the standardized J2ME™ LCDUI APIs. The LnF allows developers to modify how the standard user interface (UI) components available in J2ME™ (javax.microedition.
iDEN i325 J2ME™ Developers’ Guide 17.2. Class Description The API for the LnF is located in package com.motorola.iden.lnf. com.motorola.iden.lnf.LookAndFeel | +- com.motorola.iden.lnf.DisplayableLookAndFeel | | | +- com.motorola.iden.lnf.SystemLookAndFeel | +- com.motorola.iden.lnf.WidgetLookAndFeel | +- com.motorola.iden.lnf.ItemLookAndFeel | | | +- com.motorola.iden.lnf.CheckboxItemLookAndFeel | +- com.motorola.iden.lnf.ChoiceGroupItemLookAndFeel | +- com.motorola.iden.lnf.
iDEN i325 J2ME™ Developers’ Guide 17.3.1. Example 1 try { // instantiate the new LookAndFeel to be used by all // List and ChoiceGroup options MyCheckboxLnF cbLnF = new MyCheckboxLnF(); // replace the existing LnF with the new one LookAndFeelEngine.set(LookAndFeelEngine.LNF_ID_LCDUI_CHECKBOXITEM, cbLnF); // since we just modified the LnF used by *ALL* Lists and // ChoiceGroups, we must make all the Screens of these types // invalid so layout calculation happens and the new LnF gets used LookAndFeelEngine.
iDEN i325 J2ME™ Developers’ Guide public class MyCheckboxLnF extends CheckboxItemLookAndFeel { // the default constructor public MyCheckboxLnF() throws LookAndFeelException { } // returns the width occupied by the image and // the radio-button.
iDEN i325 J2ME™ Developers’ Guide else { h = tvh; } // consider the height of the image int ih = img.getHeight(); if (ih > h) { h = ih; } return h; } // paint the radio-button/checkbox, etc.
iDEN i325 J2ME™ Developers’ Guide // move the origin of coords so the image // or TextView is next to this icon g.translate(size, 0); break; case ITEM_LNF_ASPECT_CHECKBOX: // outer rectangle g.drawRect(0, 0, size-1, size-1); // Inner mark, if selected // (the inner mark is an x) g.drawRect(1, 1, size-3, size-3); if (selected) { g.drawLine(0, 0, size-2, size-2); g.drawLine(0, size-2, size-2, 0); } // move the origin of coords so the image // or TextView is next to this icon g.
iDEN i325 J2ME™ Developers’ Guide 18. Multimedia 18.1. Overview This chapter deals with the audio and video features of the i325. Due to the high level of devicedependant configurations allowed by JSR-135, detailed guidelines for the i325’s MMA 1.1 implementation follow. In each of the class or interface descriptions that follow, if a particular method is not listed it should be assumed that the i325 implements it as described in the Sun Javadocs for JSR-135 (MMA 1.0) or JSR-184 (MMA 1.1).
iDEN i325 J2ME™ Developers’ Guide Table 13. “System Properties Key System.getProperty( Key ) "microedition.media.version" "supports.mixing" "supports.audio.capture" "supports.video.capture" "supports.recording" "audio.encodings" "1.
iDEN i325 J2ME™ Developers’ Guide 18.3. Method Descriptions 18.3.1. Manager Methods 18.3.1.1. createPlayer Creates a Player from an input locator. public static Player createPlayer (String locator) throws IOException, MediaException For music content stored in the JAR file or in a RMS database, use the protocol file://. See also the “Locator Protocols vs. Supported Media Files” table on page 127.
iDEN i325 J2ME™ Developers’ Guide 18.3.2.2. start Starts the Player as soon as possible public void start() throws MediaException If playback does not start it may be due to the device sending a DEVICE_UNAVAILABLE event after the Player was prefetched. Avoid calling start() in a MIDlet’s startApp() method as this may cause the MIDlet' s UI to freeze at MIDlet starting or MIDlet resuming screens. 18.3.2.3. stop Stops the Player.
iDEN i325 J2ME™ Developers’ Guide 18.5. Compiling & Testing MMA MIDlets Use Sun’s Wireless Tool Kit 2.0 to compile code and package JAR / JAD files. 18.6. Tips 18.6.1. General Tips • Voicenote files are played according to voice volume, not Java volume. • The packages com.motorola.midi and com.motorola.iden.voicenote are deprecated. • At most, 10 Player objects can be in the REALIZED state or beyond. One of the 10 would have to be closed before an eleventh could be realized.
iDEN i325 J2ME™ Developers’ Guide 18.6.5. TempoControl Tips Only TempoControl is implemented on the i325 (for MIDI files only), despite inheriting methods from RateControl. All RateControl methods return –1. The range of values supported for setTempo() are 10 - 300 beats per minute. 18.6.6. RecordControl Tips This control can be used to capture iDEN Voicenote Files. Recordings to a location beginning with "file:/" are put in a temporary folder and are removed when the application exits.
iDEN i325 J2ME™ Developers’ Guide 19. Lighting 19.1. Overview The Lighting API lets a MIDlet turn on and off various lights on the phone. 19.2. Class Description The API for the Lighting API is located in package com.mot.iden.multimedia java.lang.Object | + - com.mot.iden.multimedia.Lighting 19.3. Method Description 19.3.1. Lighting Methods 19.3.1.1.
iDEN i325 J2ME™ Developers’ Guide If you pass an invalid value for either light or state, this method throws an IllegalStateException Note that the i325 does not have a status light. If you pass LIGHT_STATUS as the value for light, this method changes the state of the call indicator light instead. This lets you continue to run older applications that use the status light without needing to modify them. 19.3.1.2. javaOverRideTimer Gives an application complete control of the device’s lights.
iDEN i325 J2ME™ Developers’ Guide 20. Vibrator API 20.1. Overview The Vibrator class lets a MIDlet turn the phone’s vibrator on and off. It also provides the user with reoccurring effects that can be used with the vibrator. These effects allow the vibrator to turned on and off in reoccurring patterns. This feature is useful for games or alarms. Note that the vibrator can be turned on for a maximum of 500 ms at any given time, and it must remain off for at least 50 ms before being turned it back on.
iDEN i325 J2ME™ Developers’ Guide 20.3.1.3. vibratorOff / vibratorOn The following methods allow a MIDlet to turn the vibrator on and off: public static void vibratorOff() public static void vibratorOn() vibratorOff() stops the vibrator. vibratorOn() turns the vibrator on for MAX_VIBRATE_TIME, 500ms. 20.4. Code Examples 20.4.1. Example 1 The example below will vibrate the phone for 300 milliseconds public void vibratePhone() { /* this will have the phone vibrate for 300ms */ Vibrator.
iDEN i325 J2ME™ Developers’ Guide 21. Customer Care API 21.1. Overview The Customer Care API lets J2ME™ applications access unit and user specific data. This data may be used to track and troubleshoot issues out on the field. Specifically it will provide access to such as the unit info, system status, reset/error log, client info, my info, and Java System metrics.
iDEN i325 J2ME™ Developers’ Guide 21.3.1.2. getSystemStatus Returns system status information such as signal quality, carrier channel, carrier color code (including extended color code for supporting devices), power cutback level and serving cell quality. public static final String getSystemStatus(int fieldID) throws IllegalArgumentException fieldID must be one of the values in this table: fieldID Example of Data SQE CARRIER_CHNL COLOR_CODE PWR_CUTBACK SVG_CELL_QUALITY "34.73" "2EB" "1" "00db" "-66".
iDEN i325 J2ME™ Developers’ Guide For all fieldIDs, a null will be returned for applications in unauthorized domains. 21.3.1.5. getClientInfo Returns client information such as a unique identifier (or IMEI), the device' s serial number, and the SIM identifier.
iDEN i325 J2ME™ Developers’ Guide // Get system status methods // 7) sqe signal quality // 8) carrier channel // 9) carrier color code // 10) power cutback level // 11) serving cell quality for(int x = 7; x <12; x++){ System.out.println("System Status Methods(" + x + ") ->" + CustomerCare.getSystemStatus(x)); screen.append("System Status Methods(" + x + ") ->" + CustomerCare.
iDEN i325 J2ME™ Developers’ Guide screen.append("Java System Methods(" + x + ") ->" + CustomerCare.getSystemInfo(x)); } } catch(Exception e){ System.out.println("Something went wrong! "+ e.toString()); } } 21.5. Compiling & Testing Customer Care MIDlets In the stub classes, the methods return either 0 or null since there is no native support for them. Page 141 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide 22. Java ZIP 22.1. Overview The Java Zip API has been included as an enhancement especially well suited for a limited bandwidth data device such as an iDEN phone. It allows for file deflation before sending data via the network and inflation after receiving data from the network to best use the bandwidth available. Downloading a zipped file and then decompressing on device is usually much faster than downloading uncompressed content.
iDEN i325 J2ME™ Developers’ Guide 22.4.2. ZipOutputStream/ZipInputStream try { ByteArrayOutputStream gis = new ByteArrayOutputStream(1024); // (1) Compression: Define ZIPOutputStream with // ByteArrayOutputStream ZipOutputStream os = new ZipOutputStream(gis); ZipEntry zipentry = new ZipEntry("TEST1"); /* set the 1st entry name */ os.putNextEntry(zipentry); // (2) Writes the string to the ZIPOutputStream os.write("This chapter covers how to configure a system "+ "without a name service. Administration is ..
iDEN i325 J2ME™ Developers’ Guide 23. Smart Text Entry 23.1. Overview Text components on the i325 phone are enabled with T9 smart text entry capability. Smart text entry allows users to enter text faster by removing the need for multiple key presses in order to input certain letters or symbols. The T9 engine recognizes given key sequences and matches them with the words contained in its database.
iDEN i325 J2ME™ Developers’ Guide The screenshot on the left displays a typical email MIDlet. The focused text component is the Message box. The text within the Message box is being edited in Word mode, indicated by the icon at the bottom center of the screen and the word “application” is the returned word based on the key sequence entered. The user has pressed the ‘#’ key enabling character shift, indicated by the up arrow in the icon.
iDEN i325 J2ME™ Developers’ Guide The initial entry mode of the T9 engine can also be affected by the constraints of the text component that it services. For example, a TextField created with the TextField.PHONENUMBER constraint will create a TextField with a T9 engine set initially to Numeric entry mode. In addition, the user will not be able to access the Entry Method menu to change the input mode. Similarly, a TextField created with the TextField.
iDEN i325 J2ME™ Developers’ Guide Appendix A. A.1. Fonts on the i325 Phone Overview As MIDP states, the Font class represents fonts and font metrics. Fonts cannot be created by applications. Instead, applications query for fonts based on font attributes and the system attempts to provide a font that matches the requested attributes as closely as possible. A Font' s attributes are style, size, and face.
iDEN i325 J2ME™ Developers’ Guide A.3. Default Fonts The default font is set to FACE_SYSTEM, SIZE_MEDIUM, and STYLE_PLAIN. LCDUI components use the default font class from the com.motorola.iden.lnf package. (See “ Page 148 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide MIDP 2.0 LCDUI page 28.) The font face and size for LCDUI components defaults to FACE_SYSTEM, STYLE_PLAIN, while the size depends on the user’s selected font size in the phone’s settings. A.4. Legacy Fonts The monospace font offered in the i325 is the same font from previous Java-enabled iDEN phones. The proportional font is the same font from the i85s and i88s phones.
iDEN i325 J2ME™ Developers’ Guide Appendix B.
iDEN i325 J2ME™ Developers’ Guide Appendix C. C.1. How To Downloading to the Device The JAL utility provides the application developer a means to load an application to the i325. Additionally, a data cable is used to connect to the bottom connector on the i325. For instructions on installing the JAL utility, please consult the user guide. In order for JAL to communicate with the i325, the data-communication rates need to be in sync.
iDEN i325 J2ME™ Developers’ Guide C.2. Installation The following checklist should be covered before attempting to install a MIDlet suite. Failure to verify this checklist could lead to an installation failure. • Application supports CLDC 1.0 and MIDP 2.0 (the configuration and profile supported by the i325) • A JAD file has been created • A JAR file containing META-INF/MANIFEST.MF has been created • The MIDlet-Name, MIDlet-Version, and MIDlet-Vendor attributes are duplicated in both the MANIFEST.
iDEN i325 J2ME™ Developers’ Guide Once the application is done installing on the i325, you need to press the “Done” soft key to return to the Java Menu. If you leave the installation progress screen while the MIDlet suite is still being installed, then you return to the installation screen the next time you select Java Apps from the Main Menu. C.3. To Remove the Application Before Installing or After an Installation Failure 1. Highlight the application on the Java menu. 2. Press the “Menu” key.
iDEN i325 J2ME™ Developers’ Guide C.6. Java System Formatting and Diagnosis From the Java Apps menu, a Java System option is available to format and diagnose the Java platform on the i325. You can use these tools to diagnose the system’s integrity as well as to re-format the Program and Data Space that the Java apps use. In addition to the diagnosis and formatting tools, the Java System option provides information on platform specifications and available storage space.
iDEN i325 J2ME™ Developers’ Guide Appendix D. D.1.
iDEN i325 J2ME™ Developers’ Guide "MOZ", "MW", "MY", "NAM", "NCL", "NL", "NZ", "OMN", "PAK", "PH", "POL", "QAT", "RO", "RUS", "SA", "SDN", "SGP", "SI", "SK", "SYR", "TH", "TR", "TZ", "UKR", "UZB", "VN", "YU", "ZW", "", D.2.
iDEN i325 J2ME™ Developers’ Guide Appendix E. Playing MIDI Files The MidiPlayer API provides some basic controls for playing music. The API allows the application to start and stop playing a MIDI file and to play a single MIDI note on top of the music. E.1. Class Description The API for the MidiPlayer is located in package com.motorola.midi. The class MidiPlayer contains all the methods needed to work with MIDI. java.lang.Object | + -- com.motorola.midi.MidiPlayer E.2.
iDEN i325 J2ME™ Developers’ Guide E.5.Code Examples The following code demonstrates each of the three method calls. try { MidiPlayer.play("soap108dotcom.mid", MidiPlayer.PLAY_ONCE); int NOTE = 60; int VOL = 127; int INST = 74; /* Middle C (C3) */ /* Maximum volume */ /* Flute */ MidiPlayer.playEffect(NOTE, int key_pressure = 120, VOL, INST, int channel = 10); } catch (Exception e) { } MidiPlayer.stop(); E.6. Tips Often it is useful to tell if a MIDI is still playing (e.g.
iDEN i325 J2ME™ Developers’ Guide E.7.Compiling & Testing MIDI Capable MIDlets The stubbed MidiPlayer class is a non-functional class. The class is provided to build and run within any emulator. The class will make an attempt to display its methods’ behavior through System.out.println() statements when a method is called. play()displays “Playing a MIDI.”. stop()displays “MIDI Stopped.”. playEffect()displays “Playing a MIDI Effect….Done”. Page 159 2004 Motorola, Inc.
iDEN i325 J2ME™ Developers’ Guide Appendix F. Optional Attributes for JAD Attribute Name iDEN-MIDlet-Name- iDEN-Vendor- iDEN-MIDlet-- IDEN-MIDlet-Phone: iDEN-MIDlet-miniJIT: on MIDlet-Push- Attribute Description The name of the MIDlet suite that identifies the MIDlets to the user in language. The language codes, , can be obtained from “Internationalization Support” on page 155. The organization that provides the MIDlet suite in language.
iDEN i325 J2ME™ Developers’ Guide MOTOROLA, the Stylized M Logo and all other trademarks indicated as such herein are trademarks of Motorola, Inc. ® Reg. U.S. Pat. & Tm. Off. © 2003 Motorola, Inc. All rights reserved. Microsoft and, Microsoft WEB Explorer, are registered trademarks of Microsoft Corporation. Java and all other Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.