Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: jimmackPosted on 2004-05-07 at 00:43:02ID: 11012703
Before worrying about the details of Bluetooth, I would ensure that the MIDlets are displaying something useful so that you can begin debugging. You have shown the code for two MIDlets. How are you executing these? Are you running two emulators, one with the client and one with the server?
{ mmand); r(this); etCurrent( mainForm);
; etCurrent( f);
");
();
T, 1)); ; etCurrent( f);
r");
();
When you say "black screen", do you mean "blank screen"? Is there no Form title or exit command?
The most likely reason that nothing is being displayed is that your form is being displayed in the same thread that is attempting the bluetooth connection. If the connection is blocked, then the form probably won't be displayed. I would suggest that you modify the BluetoothMIDlet as follows:
public class BluetoothMIDlet extends MIDlet implements Runnable, CommandListener {
private Command exitCommand;
public BluetoothMIDlet(){
exitCommand = new Command("Sair", Command.EXIT, 1);
}
public void startApp() throws MIDletStateChangeException
mainForm = new Form("???");
mainForm.addCommand(exitCo
mainForm.setCommandListene
Display.getDisplay(this).s
new Thread(this).start();
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
public void run(){}
public void commandAction (Command c, Displayable d){
if (c == exitCommand){
destroyApp(true);
notifyDestroyed();
}
}
}
This will display the form in the main thread, separately from the bluetooth connection attempt.
You'll also need to modify the client and server "run()" methods:
Client:
public void run(){
// Form f = new Form("Cliente");
// f.addCommand(new Command("Sair", Command.EXIT,1));
// f.setCommandListener(this)
// Display.getDisplay(this).s
mainForm.setTitle("Cliente
try {
LocalDevice local = LocalDevice.getLocalDevice
.
.
.
Server:
public void run(){
// Form f = new Form("Servidor");
// f.addCommand(new Command("Sair",Command.EXI
// f.setCommandListener(this)
// Display.getDisplay(this).s
mainForm.setTitle("Servido
try{
LocalDevice local = LocalDevice.getLocalDevice
.
.
.
When the display is working, you should get some more useful output :-)