?? starter.java
字號(hào):
package Reader;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
/**
* Test class for GPS. Not needed for application.
*
* @author Dominik Schmidt
*/
public class Starter extends MIDlet implements CommandListener, Runnable {
// private static final String GPS_BT_URL = "comm:0;baudrate=9000";
private static final String GPS_BT_URL = "file:///C:\\Users\\Jack\\j2mewtk\\2.5.2\\appdb\\DefaultColorPhone\\filesystem\\root1\\Gps.dat";
// C:\Users\Jack\j2mewtk\2.5.2\appdb\DefaultColorPhone\filesystem\root1
private Command exitCommand;
private Command pauseCommand;
private Command resumeCommand;
private Display display;
private static final long BREAK = 500;
private Logger nn = new Logger("GPS Test", 512, 0);
private Thread runner;
private GPSReader gps;
public Starter() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 0);
pauseCommand = new Command("Pause", Command.SCREEN, 2);
resumeCommand = new Command("Resume", Command.SCREEN, 2);
}
public void startApp() {
// System.out.print("------------------");
nn.addCommand(exitCommand);
nn.addCommand(pauseCommand);
nn.addCommand(resumeCommand);
nn.setCommandListener(this);
display.setCurrent(nn);
gps = new GPSReader(nn , GPS_BT_URL);
gps.start();
start();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
stop();
gps.stop();
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
else if(c == pauseCommand) {
stop();
gps.stop();
}
else if(c == resumeCommand) {
start();
gps.start();
}
}
public void run() {
while (Thread.currentThread() == runner) {
try {
Record record = gps.getRecord();
nn.setTitle("W: " + record.warning);
nn.setString(record.dateTimeOfFix + "\n" + record.lattitude
+ "," + record.longitude + ", " + record.quality + ", "
+ record.satelliteCount);
} catch (EmptyBufferException e) {
nn.setString("No data received yet.");
}
try {
Thread.sleep(BREAK);
} catch (InterruptedException e) {
}
}
}
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop() {
runner = null;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -