Prev | Current Page 241 | Next

Timothy J. Thompson, C Bala Kumar, and Paul Kline

"Bluetooth Application Programming with the Java APIs Essentials Edition"

If one did occur
// display an Alert before allowing the application
// to exit.
if (type != DiscoveryListener.INQUIRY_COMPLETED) {
// If the device inquiry was terminated, then the
// user must have selected a RemoteDevice to
// perform a service search on so start the
// service search.
if (type == DiscoveryListener.INQUIRY_TERMINATED) {
startServiceSearch();
return;
} else {
dialog = new Alert("Bluetooth Error",
"The inquiry failed to complete normally", null,
AlertType.ERROR);
}
} else {
dialog = new Alert("Inquiry Completed",
"The inquiry completed normally", null,
AlertType.INFO);
}
200 Chapter Seven: Service Discovery
dialog.setTimeout(Alert.FOREVER);
Display.getDisplay(this).setCurrent(dialog);
}
}
The startServiceSearch() method is called from two different parts
of the previous code. The startServiceSearch() method is called
from the commandAction() method if an inquiry is not in progress. If
an inquiry is in progress, the commandAction() method cancels the
inquiry and the startServiceSearch() method is called from the
inquiryCompleted() method when the cancel is processed.
The startServiceSearch() method starts the service search.
This method performs a service search for the Bluetooth game service
described earlier in this chapter. When a service is found with the Bluetooth
game service??™s UUID, the 0x100 attribute also is retrieved.


Pages:
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253