| Reply | « Previous Thread | Next Thread » |
|
Hi!
I've been trying to write a program that will allow a service to be run continuously in the background on a 6600 but I also want to be able to turn the service on and off as required. I read that the way to close a service and remove the service record from the SDDB is to call close() on the StreamConnectionNotifier. However, if a device hasn't been found, when I do this it causes a RuntimeException saying "Connection Closed during acceptAndOpen". I'm new to JABWT so I expect it's me being a muppet but if anyone could help me out with this I'd be very grateful. I've included the relevent section of code below. Thanks! public void run() { try { // Create the server connection object service = (StreamConnectionNotifier)Connector .open("btspp://localhost:" + uuid.toString() +";name=" + serviceName); // Retrive the service record template rec = localDevice.getRecord(service); } catch (java.io.IOException ioe) { System.out.println(ioe.getMessage()); } while (running) { try { // Open the service ready for accepting connections conn = service.acceptAndOpen(); } catch (java.io.IOException e1) { System.out.println(e1.getMessage()); if (conn != null) try { conn.close(); } catch (java.io.IOException e2) { System.out.println(e2.getMessage()); } } } // while running } // end run() public void stopService() { running = false; try { service.close(); // Close the StreamConnectionNotifier } catch (Exception ex) { System.out.println(ex.getMessage()); } } |
|
Hmm... reading around I saw mentioned that this might be a problem with the
Series 60 MIDP Concept SDK Beta 0.3.1. I found that the same error occurs in Ben Hui's BlueChat application when you hit the exit button. Can anyone confirm that this is an emulator problem? I would be very grateful for any help - I've lost nearly a week trying to sort this out already! Thanks in advance! |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|