I make a simple BT chat. Part of the code is taken from the Google sample. So the question is, can we search only devices on which the client of our BT chat is installed or available in the search for devices (maybe our BT socket is running)? Sample google
1 answer
Sure you may. The search for devices is divided into 2 phases:
- Device discovery - search for devices (at least some). A Bluetooth device is required to have
DiscoveryAgent
- a device discovery agent. The result of the search will be an array ofRemoteDevice
. Example for example here - Next, you can organize a search for services in the
RemoteDevice
array. TheDiscoveryAgent.searchServices()
method is responsible for this. Only it is necessary not to forget that it is necessary to register on the remote device what services it "puts" outside. This is done through the publication in the so-called. SDDB - Service Discovery Database (the whole procedure is described here )
- It remains to fasten here developer.android.com/resources/samples/BluetoothChat/src/com/ ... It is necessary to output only those that have the service of the same program - AndroidDev
- oneWell, fasten - who is the developer? Me or you? - Barmaley
- (the whole procedure is described here) The link is not working) - AndroidDev
- oneI would like to try, and the link dosihpor refers to the hashcode - AndroidDev
- corrected the link - Barmaley
|