Stack Overflow is a community of 4.7 million programmers, just as you and helping each other. Join them, it only takes a minute:android-get Bluetooth UUID for this device
| Up vote 9 down vote favorite7 |
I was browing Stack and the Internet for a simple solution to get the UUID device I ' m currently using. I stumbled over posts like this but none of the them seemed to the help me. The doc tells me about this getUuids() function if going through the doc for Android Bluetooth I end up have a bluetoot Hadapter but I need a to the BluetoothDevice execute this function. So I need to know the following: 1) is the function returning really the device UUID ? Because the name saids plural (getuuid s ) 2) How does I get an instance of this BluetoothDevice ? thanks! Android Bluetooth UUID Android-bluetooth
| ShareImprove this question |
Asked Oct at 9:12 Ron 5,0109 |
|
|
|
|
Anyway, how could are know the UUID is for your Bluetooth device @Ron? –gumuruh Jul 7 ' + at 7:23 |
Add a Comment |
1 Answer Active oldest votes
| Up vote vote accepted |
Using reflection you can invoke the hidden method on the getUuids() BluetoothAdater : BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();Method getUuidsMethod = BluetoothAdapter.class.getDeclaredMethod("getUuids", null);ParcelUuid[] uuids = (ParcelUuid[]) getUuidsMethod.invoke(adapter, null);for (ParcelUuid uuid: uuids) { Log.d(TAG, "UUID: " + uuid.getUuid().toString());}
The result on a Nexus S: UUID: 00001000-0000-1000-8000-00805f9b34fbUUID: 00001001-0000-1000-8000-00805f9b34fbUUID: 00001200-0000-1000-8000-00805f9b34fbUUID: 0000110a-0000-1000-8000-00805f9b34fbUUID: 0000110c-0000-1000-8000-00805f9b34fbUUID: 00001112-0000-1000-8000-00805f9b34fbUUID: 00001105-0000-1000-8000-00805f9b34fbUUID: 0000111f-0000-1000-8000-00805f9b34fbUUID: 0000112f-0000-1000-8000-00805f9b34fbUUID: 00001116-0000-1000-8000-00805f9b34fb
Where, for instance 0000111f-0000-1000-8000-00805f9b34fb HandsfreeAudioGatewayServiceClass 00001105-0000-1000-8000-00805f9b34fb OBEXObjectPushServiceClass . Actual availability of this method is depend on device and firmware version.
| ShareImprove this answer |
answered Oct at 20:36 Stefano S. 16413 |
|
|
|
|
i ' m using SDK16 and it doesn ' t work for me. The UUIDs is null . Furthermore I ' d like to has just my Bluetooth uuid. Do you know how to get this one? – ron Oct "at 8:08 |
|
|
there is a UUID for each Bluetooth service exposed by the device; That's why you see multiple UUIDs for the smartphone. I performed the tests using SDK on Nexus S with Android 4.1.2 and Galaxy Nexus with Android 4.3. Which device did you use? – stefano S. oct "at 9:34 |
|
|
bluetooth have to IS On. I tested on a Galaxy S2 with Android 4.1.2 and it worked, showing-UUIDs. – stefano S. oct "at 13:10 |
|
|
ok, thats great so f Ar-thanks:) But what do I get the UUID representing my phone? Or does I need all of them for identifying my devide? – ron Nov 4 ' at 15:08 |
|
|
@Ron, are there any got you wanted? I also want to ask. Is it okay if I define my own UUID for the different Android devices to communicate each other? I mean, wouldn ' t it is conflict if I use the same same UUID for both different device? –gumuruh Jul 7 ' + at 7:24 |
Show5More comments |
Your Answer
Stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device
<textarea id="wmd-input" class="wmd-input" tabindex="101" name="post-text" rows="15" cols="92" data-min-length=""></textarea>Stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device
Android-get Bluetooth UUID for this device