Telephone call function in J2ME and WAP

Source: Internet
Author: User

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).

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 Com  Mandlistener {
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);
The
public void Pauseapp () {}
is public void Destroyapp (Boolean unconditional) {}
public void Commandaction (Comm and 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:

<input name="phone_no" format="*m" value="13"/>
<do type="option" label="呼出号">
<go href="wtai://wp/mc;$(phone_no)"/>
</do><br/>
或者直接写入电话号码的方式:
<a href="wtai://wp/mc;1331597312*">拨打电话</a>

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.