This article describes how to implement phone call functions on J2ME platforms and WAP pages. The differences between WAP and J2ME are not discussed, and readers can access the data themselves. There is no function in MIDP 1.0 to provide phone calls. In MIDP 2.0, the Javax.microedition.midlet.MIDlet class provides a platformrequest () method to request a device to complete a specific request, the content of which is requested by Platformrequest () method is identified by the string type parameter URL of the It might be a call to the browser to open a specific WAP page or a call call. When device resources are available, the system puts the midlet in the background and executes the specific application, such as a phone program or browser, in the foreground. When calling a call, you can use the following form:
try{
This.platformrequest ("tel:13810000000");
}catch (Connectionnotfoundexception ex) {
Ex.printstacktrace ();
}
This provides a simple example of a successful call to the specified phone on the test pass on the Nokia 7610 (Support MIDP 2.0).
/*
* Telemidlet.java
*
* Created on December 15, 2005, 9:56
*/
Package com.j2medev.call;
Import javax.microedition.io.ConnectionNotFoundException;
Import javax.microedition.midlet.*;
Import javax.microedition.lcdui.*;
/**
*
* @author Administrator
* @version
*/
public class Telemidlet extends MIDlet implements Commandlistener {
Private display display = NULL;
Private List main = null;
public void startApp () {
if (display = = null) {
display = Display.getdisplay (this);
main = new List ("Test phone function", list.implicit);
Main.append ("13810000000", null);/The phone number here is virtual.
Main.append ("13810000001", null);/The phone number here is virtual.
Main.setcommandlistener (this);
}
Display.setcurrent (main);
}
public void Pauseapp () {}
public void Destroyapp (Boolean unconditional) {}
public void Commandaction (Command cmd,displayable displayable) {
if (cmd = = List.select_command) {
String number = main.getstring (Main.getselectedindex ());
try{
This.platformrequest ("Tel:" +number);
}catch (Connectionnotfoundexception ex) {
Ex.printstacktrace ();
}
}
}
}
Compared with J2ME technology, WAP is more similar to web, it is a server-oriented technology. The Wtai function of the device can be invoked in WML to call a specific phone number, as shown in the following code:
or write the phone number directly:
call
Support for phone calls is provided in the MIDP 2.0 and WAP platforms, and this article is a simple summary of what is expected to help your actual project.