📄 nativemidlet.java
字号:
/*
* NativeMIDlet.java
*
* Created on 2007年10月6日, 下午5:16
*/
package com.j2medev.chapter3;
import javax.microedition.io.Connection;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.ConnectionNotFoundException;
/**
*
* @author NeNo
* @version
*/
public class NativeMIDlet extends MIDlet implements CommandListener {
private Display display = null;
private List main = new List ("menu",List.IMPLICIT);
private Command exitCommand = new Command("Exit",Command.EXIT,1);
public static final String WAP_BROWSER = "wap browser";
public static final String TELEPHONE = "call telephone";
public void startApp() {
if(display == null) {
display = Display.getDisplay(this);
main.append(WAP_BROWSER,null);
main.append(TELEPHONE,null);
main.addCommand(exitCommand);
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 label = main.getString(main.getSelectedIndex());
String URL = "";
if(label.equals(WAP_BROWSER)){
URL = "http://www.j2medev.com";
}else if(label.equals(TELEPHONE)){
URL = "tel:13950187672";
}
try{
boolean flag = platformRequest(URL);
if(flag){
exit();
}
}catch(ConnectionNotFoundException ex){
ex.printStackTrace();
Alert a = new Alert("error",ex.getMessage(),null,AlertType.ERROR);
a.setTimeout(2000);
showAlert(a);
}
}else if(cmd == exitCommand){
exit();
}
}
private void showAlert(Alert alert){
display.setCurrent(alert,main);
}
private void exit(){
destroyApp(false);
notifyDestroyed();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -