You Are Here:

Community: Developer Discussion Boards

#1 Old Stopping/Removing a Service - 2004-07-06, 17:00

Join Date: Jul 2004
Posts: 8
bodhix
Offline
Registered User
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());
}
}
Reply With Quote

#2 Old 2004-07-07, 17:36

Join Date: Jul 2004
Posts: 8
bodhix
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia