Telephone call function in J2ME and WAP

Source: Internet
Author: User
Tags string
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.