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\
strings.xml
goes in <ProjectRoot>\res\values\
main.xml
goes in <ProjectRoot>\res\layout\
AndroidManifest.xml
goes in <ProjectRoot>
Screen Capture from Acer A100
Notes:
- 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.

4 comments:
Is it possible to get the full package in a zip file ?
re: Anonymous
Done, see above.
Thanks, im using your code, when i receive of extre.uuid
Parcelable[] uuidExtra = intent.getParcelableArrayExtra("android.bleutooth.device.extra.UUID");
uuidExtra obj is always null.so im not able to parse it. it gives nullpointerexception. what i m doing wrong?
I'm seeing null for that on some devices and broadcasts, but not for others. I'd recommend just checking for null and skipping that item. That worked for me to prevent crashing enough to list other valid entries.
Post a Comment