(Difference between revisions)

Making a phone call using TextField in Java ME

From Nokia Developer Wiki
Jump to: navigation, search
debjit.roy (Talk | contribs)
(Debjit.roy -)
hamishwillee (Talk | contribs)
Line 1: Line 1:
[[Category:Java ME]][[Category:MIDP 2.0]][[Category:Code Examples]][[Category:Telephony]][[Category:S60 3rd Edition, Feature Pack 1]][[Category:Code Snippet]]
[[Category:Java ME]][[Category:MIDP 2.0]][[Category:Code Examples]][[Category:Telephony]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]

Revision as of 08:02, 9 May 2012


Article Metadata
Tested with
Devices(s): Nokia N95 8GB
CompatibilityPlatform Security
Capabilities: )
Keywords: javax.microedition.lcdui.TextField
Created: tapla (14 May 2008)
Last edited: hamishwillee (09 May 2012)

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


This snippet demonstrates how to make a phone call by using a TextField. The MIDlet constructs a phone number field and displays it on the screen. The user may enter a phone number into it or obtain one from the Contacts list. After that, he or she can select Options > Call to call that number.


import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
public class ExampleMIDlet extends MIDlet implements CommandListener {
private Command exitCommand;
private Form mainForm;
* Constructor. Constructs the object and initializes displayables.

public ExampleMIDlet() {
mainForm = new Form("ExampleMIDlet");
// Create a phone number field, which allows a call to be made
mainForm.append(new TextField("Phone number", null, 20,
exitCommand = new Command("Exit", Command.EXIT, 0);
* Called when the MIDlet is started.

public void startApp() {
// Other inherited methods omitted for brevity
// ...
* From CommandListener.
* Called by the system to indicate that a command has been invoked on a
* particular displayable.
* @param command the command that was invoked
* @param displayable the displayable where the command was invoked

public void commandAction(Command command, Displayable displayable) {
if (command == exitCommand) {
// Exit the MIDlet


A phone number field is displayed on the screen. The user can enter a phone number and select Options > Call to call that number.

See also

251 page views in the last 30 days.