📄 helloworldmidlet.java
字号:
package firstj2me;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.ConnectionNotFoundException;
public class HelloWorldMIDlet extends MIDlet implements CommandListener {
public static HelloWorldMIDlet helloInstance;
Form mainfrm = new Form("platformRequest 测试");
String telStr = "15879180878";
String urlStr = "http://wap.sina.com";
Command dialCmd, linkCmd;
public HelloWorldMIDlet() {
helloInstance = this;
mainfrm.append("要呼叫的号码为:\n");
mainfrm.append(telStr);
mainfrm.append("\n要连接WAP页面为:\n");
mainfrm.append(urlStr);
linkCmd = new Command("连接", 7, 1);
dialCmd = new Command("拨号", 1, 2);
mainfrm.addCommand(dialCmd);
mainfrm.addCommand(linkCmd);
mainfrm.setCommandListener(this);
}
public void startApp() {
Display.getDisplay(this).setCurrent(mainfrm);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable d) {
if (c == dialCmd) {
try {
this.platformRequest("tel:" + telStr);
}
catch (ConnectionNotFoundException ex) {}
}
if (c == linkCmd) {
try {
this.platformRequest(urlStr);
}
catch (ConnectionNotFoundException ex) {}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -