nnectable(true); BCC.setDiscoverable(DiscoveryAgent.GIAC);
. . .
列表B
. . .
// retrieve the local Bluetooth device object LocalDevice local = LocalDevice.getLocalDevice();
// retrieve the name of the local Bluetooth device
String name = local.getFriendlyName();
. . .
列表C
. . . LocalDevicelocaldevice = LocalDevice.getLocalDevice(); DiscoveryAgentdiscoveryAgent = localdevice.getDiscoveryAgent(); discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this);
. . .
列表D
...
// Service registration
// invoke Connector.open with a server connection URL argument StreamConnectionNotifier service = (StreamConnectionNotifier) Connector.open("someURL");
// Obtain the service record created by the server device ServiceRecordsr = local.getRecord(service);
// Indicate that the service is ready to accept a client connection. acceptAndOpen() blocks
// until a client connects. StreamConnection connection = (StreamConnection) service.acceptAndOpen();
// DO SOME EXCHANGE HERE
service.close();
列表E
...
String url = serviceRecord.getConnectionURL( record.NOAUTHENTICATE_NOENCRYPT, false);
// open a connection to the server StreamConnection connection = (StreamConnection) Connector.open(url);
// Send/receive data
try { byte buf[] = new byte[200]; String msg = "Test message"; InputStream is = connection.openInputStream(); OutputStreamos = connection.openOutputStream(); // send data to the server os.write(msg.getBytes); // read data from the server is.read(buf); connection.close();
} catch(IOException e) { e.printStackTrace();
}
...
上一页 [1] [2] 上一页 [1] [2]
|