giovedì 28 maggio 2009

Primo programma sul controllo di un cellulare con bluetooth

SVOLTO IN CLASSE


import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.bluetooth.*;

public class Probe extends MIDlet implements CommandListener {
Form f;
//DeviceDiscoverer dd;
//ServiceDiscoverer sd;

Command exit;
Command findD;
Command findS;
Command server;

public Probe() {
f=new Form("Sonda Bluetooth");
exit=new Command("Esci",Command.EXIT,0);/*PRIORITà PIù BASSA APPARE QUESTO PER APRIRE IL MENù*/
findD=new Command("Cerca Dispositivi", Command.OK,0);
findS=new Command("Cerca Servizi", Command.OK,0);
server=new Command("SERVER",Command.OK,0);

f.addCommand(exit);
f.addCommand(findD);
f.addCommand(findS);
f.addCommand(server);
f.setCommandListener(this);
}
/* punto di partenza dell'applicativo per far apparire la form e il primo oggetto: Start App*/
public void startApp() {
Display.getDisplay(this).setCurrent(f);
}


public void pauseApp() {}
public void destroyApp(boolean undconditional){}
public void commandAction(Command c,Displayable s) {
if(c.getLabel().equals("Esci")) {
notifyDestroyed();
}
}

}

Nessun commento: