A very important feature is provided in MIDP 2.0: call external platform services, such as start downloading and installing a MIDlet kit from the network, initiating a voice call. If you have a communication, you can call the telephone service directly to call a number. The above functions can be implemented by the MIDP2.0.
Refer to Java Doc, Java Doc, you can find that he only has a string type URL. When you call him, he will pass this URL to the application management software. Apply management software to determine whether this parameter is reasonable, whether there is a related service available. If the service is available and requires MIDlet to exit to execute the calling service, then the method returns a Boolean type TRUE. If the service does not exist, it will throw ConnectionNotFoundExcepton.
In the MIDP2.0 specification, two service types are defined: 1: If the URL pointing is a JAR file or jad file, such as http://www.j2medev.com/hello.jad, then the platform will start a normal The installation process is installed. 2: If the URL starts with Tel:, for example, Tel: 01062289873, the parameter passes to the phone service program to initiate a voice call, and the caller is the back phone number. Equipment manufacturers can freely implement other platform services, such as calling web browser browsing web pages, and so on. We must know that this method is not a way to block.
Support for this method in WTK2.1, you just need to configure it. Suppose your WTK installation directory is wtk_home, then go to wtk_home / lib, editing the system.config file, add a sentence inside: com.sun.midp.midlet.platformRequestCommand: "C: / Program files / myie2 / myie.exe ". Note that you must write this sentence in a row, don't change. This way we pass similar to this URL, http://www.j2medev.com to PlatformRequest (), the system will start myie to open www.j2medev.com's homepage. Since my phone can't support MIDP2.0 so I can't test phone calls, MIDlet downloads platform services. If you can, you can write code test. Here is the code I have written in the simulator. When the user presses the Invoke button, Myie open http://www.j2medev.com. 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 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; 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 ();}}}
}