Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 12:16, 14 May 2008.

CS000955 - Making a phone call using TextField

From Forum Nokia Wiki


ID CS000955 Creation date May 14, 2008
Platform S60 3rd Edition, FP1 Tested on devices Nokia N95 8GB
Category Java ME Subcategory Telephony


Keywords (APIs, classes, methods, functions): javax.microedition.lcdui.TextField

Overview

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.

Source

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,
                TextField.PHONENUMBER));
        
        exitCommand = new Command("Exit", Command.EXIT, 0);
        mainForm.addCommand(exitCommand);
        mainForm.setCommandListener(this);
    }
    
    /**
     * Called when the MIDlet is started.
     */
    public void startApp() {
        Display.getDisplay(this).setCurrent(mainForm);
    }
    
    // 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
            destroyApp(true);
            notifyDestroyed();
        }
    }

Postconditions

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

Related Discussions
Thread Thread Starter Forum Replies Last Post
dial using pc connectivity cable HMI1974 PC Suite API and PC Connectivity SDK 1 2002-12-02 06:21
RichTextEditor Issues mayankkedia General Symbian C++ 0 2005-02-22 12:07
j2me Add contacts through textbox crashes amitkankani Mobile Java General 4 2008-03-31 11:20
Making a call , only workable once fanyulong Symbian 5 2005-07-07 10:09
Contact List to Textfield crazy_higer WRT Widget Development 0 2008-05-29 12:41
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX