Midp2.0 provides a very important function: to call external platform services, such as downloading and installing a MIDlet suite from the network, and initiating voice calls. If you have a communication record, you can directly call the telephone service to call a number. In midp2.0, you can use the MIDlet. platformrequest () method to implement the above functions.
For more information, see javax. microedition. MIDlet. MIDlet. java Doc of platformrequest (). You can find that this parameter only has a string-type URL. When you call this URL, it will be passed to the application management software. Application Management software to determine whether this parameter is reasonable and whether related services can be used. If the service is available and requires the MIDlet to exit before executing the called service, the method returns a Boolean value of true. If the service does not exist, connectionnotfoundexcepton is thrown.
The midp2.0 Specification defines two service types:
1: If the URL points to a jar or JAD file, for example, http://www.j2medev.com/hello.jad, then the platform will start a normal installation process.
2: If the URL starts with Tel:, for example, tel: 01062289873, the parameter will be passed to the telephone service program to initiate a voice call, And the called party will be the subsequent phone number.
Device manufacturers can freely implement other platform services, such as calling Web browsers to browse Web pages. We must be clear that this method is not a blocking method.
This method is supported in wtk2.1. You only need to configure it. Assume that your wtk installation directory is wtk_home, go to wtk_home/lib and edit system. add the following to the config file: COM. sun. MIDP. MIDlet. platformrequestcommand: "C:/program files/myie2/myie.exe ". Be sure
Write this sentence in a line without line breaks. In this way, when we pass a URL like this, the http://www.j2medev.com to platformrequest (), the system will start myie to open the home page of www.j2medev.com. Because my mobile phone does not support midp2.0, I cannot test the telephone call, MIDlet download, and other platform services. If you can, write code to test it. Below is the code I wrote in the simulator for a test, when the user presses the invoke button, myie open the http://www.j2medev.com normally.
Package com. j2medev. mingjava;
Import javax. microedition. MIDlet. MIDlet;
Import javax. microedition. MIDlet. midletstatechangeexception;
Import javax. microedition. Io. connectionnotfoundexception;
Import javax. microedition. lcdui .*;
Public class platformtest extends MIDlet implements commandlistener
{
Private display;
Private form mainform;
Public static final command getcommand = new command ("INVOKE", command. Item, 1 );
Public static final string url = "http://www.j2medev.com ";
Protected void Startapp () throws midletstatechangeexception
{
Display = display. getdisplay (this );
Mainform = new form ("platform test ");
Mainform. append ("click the button/" INVOKE /"");
Mainform. addcommand (getcommand );
Mainform. setcommandlistener (this );
Display. setcurrent (mainform );
}
Protected void pauseapp ()
{
}
Protected void destroyapp (Boolean arg0) throws midletstatechangeexception
{
}
Public void commandaction (command cmd, displayable disp)
{
If (cmd = getcommand)
{
Try
{
Boolean flag = platformrequest (URL );
System. Out. println (FLAG );
}
Catch (connectionnotfoundexception E)
{
E. printstacktrace ();
}
}
}
}