Tools

Namespaces

Variants

Views

Actions

Search

Contents

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Contents

Overview

This code snippet demonstrates how to add a specific contact to the contact list of the device using Java ME.

The application creates a few input fields. After the user fills them in and presses the «Save» button, contact information with entered data will be added to the contact list, using the method ContactList.createContact().

/** * From MIDlet. * Called when the MIDlet is started. */publicvoid startApp(){// Check for availability of PIM interface.if(System.getProperty("microedition.pim.version")==null){ showError("PIM API not supported.", form);}}

/** * From MIDlet. * Called to signal the MIDlet to enter the Paused state. */publicvoid pauseApp(){// No implementation required.}

/** * From MIDlet. * Called to signal the MIDlet to terminate. * @param unconditional whether the MIDlet has to be unconditionally * terminated */publicvoid destroyApp(boolean unconditional){// No implementation required}

/** * From CommandListener. * Called by the system to indicate that a command has been invoked on a * particular displayable. * @param cmd the command that was invoked * @param displayable the displayable where the command was invoked */publicvoid commandAction(Command cmd, Displayable displayable){if(cmd == exitCommand){ notifyDestroyed();}elseif(cmd == addCommand){ saveContact();}}