Java Reference
In-Depth Information
When using the selectService() method, the code to obtain a connection to a desired
service given its UUID is reduced to two lines:
String dateConnect = mDiscoveryAgent.selectService(DATING_SERVICE_ID,
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
StreamConnection conn = (StreamConnection) Connector.open(dateConnect);
Access to Remote Devices
The previous section shows how to search for services on a RemoteDevice . If you are working
with Bluetooth at a device level, the RemoteDevice instance also has security methods to
authenticate and encrypt a connection:
boolean authenticate();
boolean authorize(Connection conn) ;
boolean encrypt(Connection conn, boolean on);
And a set of methods to test the security status of the connection:
boolean isAuthenticated() ;
boolean isAuthorized(javax.microedition.io.Connection conn) ;
boolean isEncrypted() ;
boolean isTrustedDevice();
Note When you create a server-side notifier using the GCF (shown later in the section entitled “Creating
a Bluetooth Service”), you can specify an attribute on the connect string that indicates whether the service
requires authentication, authorization, or encryption. If used, authentication must always be performed first
before encryption or authorization.
The Bluetooth address and the user-understandable name of the device can be obtained
via the following:
String getBluetoothAddress() ;
String getFriendlyName(boolean alwaysAsk) ;
If you have a GCF connection opened to a service, and you want to get the corresponding
remote device, there is a static method that you can use:
static RemoteDevice getRemoteDevice(Connection conn) ;
 
Search WWH ::




Custom Search