Revision as of 11:19, 3 July 2012 by mtilli (Talk | contribs)

Making a phone call programmatically using platformRequest() in Java ME

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Code ExampleTested with
Devices(s): Nokia N95 8GB, Nokia 701, Nokia Asha 305
Keywords: javax.microedition.midlet.MIDlet.platformRequest()
Created: tapla (07 May 2008)
Last edited: mtilli (03 Jul 2012)



This snippet demonstrates how to make a phone call by using a platform request. The MIDlet constructs a menu item through which the user can call the specified number. After the platform request has been made, the user is prompted whether he or she wants to make a voice call, a video call, or an Internet call.


import javax.microedition.io.ConnectionNotFoundException;
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.midlet.MIDlet;
public class ExampleMIDlet extends MIDlet implements CommandListener {
private Command callCommand;
private Command exitCommand;
private Form mainForm;
// The phone number to call
private final String PHONE_NUMBER = "123456789";
* Constructor. Constructs the object and initializes displayables.

public ExampleMIDlet() {
mainForm = new Form("ExampleMIDlet");
callCommand = new Command("Call", Command.SCREEN, 0);
* Calls the specified number.

private void call(String number) {
try {
platformRequest("tel:" + number);
} catch (ConnectionNotFoundException ex) {
* Called when the MIDlet is started.

public void startApp() {
* Called when MIDlet is paused.

public void pauseApp() {
* Called to signal the MIDlet to terminate.
* terminated and all resources has to be released.

public void destroyApp(boolean unconditional) {
* From CommandListener.
* 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 == callCommand) {
} else if (command == exitCommand) {
// Exit the MIDlet


The user can select Call to call the specified number. He or she may also select whether the call should be a voice call, a video call, or an Internet call.

See also

261 page views in the last 30 days.