There is one mystery that has me perplexed. Two identical sets of services are returned for each device. In the Android documentation it states that fetchUuidsWithSdp() will:
If there is an error in getting the SDP records or if the process takes a long time, ACTION_UUID intent is sent with the UUIDs that is currently present in the cache.It is conceivable that the first set of responses is from cache and the second is from the remote device.
This example also demonstrates the use of a BroadcastReceiver, Intent Filters and a scrolling TextArea.
I have included the files that have content that is key to setting up the application.
You should be able to create a new Android project in eclipse and then copy the code included below into the appropriate file. Because fetchUUidsWithSDP() is called directly this example requires ICS or higher.
Below the code attachments you will find a screen capture of what it looks like running on my Acer A100.
If you have any suggestions or questions please post them as comments.
Download Zip Archive of Android Source FilesDiscoverDevicesAndServices.java
goes in <ProjectRoot>\src\com\example\discoverdevicesandservices\
goes in <ProjectRoot>\res\values\
goes in <ProjectRoot>\res\layout\
goes in <ProjectRoot>
Screen Capture from Acer A100
- Due to fetchUuidsWithSDP() this requires API Release 15
- As the SDK Emulator doesn’t emulate bluetooth this example will not run in the emulator.
- This example is built upon the work of others. I post it here not as an example of original work but rather as a complete working example for reference. If I didn't appropriately credit you for your work please let me know and I will add you.