×
Namespaces

Variants
Actions
(Difference between revisions)

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

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
Forum Nokia KB (Talk | contribs)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
__NOEDITSECTION__
 
__NOEDITSECTION__
 
+
{{KBCS}}
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
|-
 
|-
|'''ID''' ||  
+
|'''ID''' || CS000956
|'''Creation date''' || May 7, 2008
+
|'''Creation date''' || May 14, 2008
 
|-
 
|-
 
|'''Platform''' || S60 3rd Edition, FP1
 
|'''Platform''' || S60 3rd Edition, FP1
Line 22: Line 22:
 
==Overview==
 
==Overview==
  
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.
+
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.
  
 
==Source==
 
==Source==
Line 100: Line 100:
 
==Postconditions==
 
==Postconditions==
  
The user may select <tt>Call</tt> 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.
+
The user can select <tt>Call</tt> 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==
 
==See also==
  
* [[Making a phone call: TextField]]
+
* [[CS000955 - Making a phone call using TextField]]
  
 
[[Category:Java ME]][[Category:MIDP 2.0]][[Category:Code Examples]][[Category:Telephony]]
 
[[Category:Java ME]][[Category:MIDP 2.0]][[Category:Code Examples]][[Category:Telephony]]
 +
[[Category:S60 3rd Edition]]

Revision as of 15:19, 14 May 2008


Template:KBCS

ID CS000956 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.midlet.MIDlet, javax.microedition.midlet.MIDlet.platformRequest()

Overview

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.

Source

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 = "0700123123";
 
/**
* Constructor. Constructs the object and initializes displayables.
*/

public ExampleMIDlet() {
mainForm = new Form("ExampleMIDlet");
 
callCommand = new Command("Call", Command.SCREEN, 0);
mainForm.addCommand(callCommand);
 
exitCommand = new Command("Exit", Command.EXIT, 0);
mainForm.addCommand(exitCommand);
 
mainForm.setCommandListener(this);
}
 
/**
* Calls the specified number.
*/

private void call(String number) {
try {
platformRequest("tel:" + number);
} catch (ConnectionNotFoundException ex) {
// TODO: Exception handling
}
}
 
/**
* 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 == callCommand) {
call(PHONE_NUMBER);
} else if (command == exitCommand) {
// Exit the MIDlet
destroyApp(true);
notifyDestroyed();
}
}

Postconditions

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

396 page views in the last 30 days.
×