How to get the UUID of a Bluetooth device?

I need to know the UUID by API 8 (2.2) or, possibly, 2.3.3.

As I understand the documentation, this should be allowed:

    phoneDevice = blueAdapter.getRemoteDevice(phoneAddress);
    ParcelUuid[] phoneUuids = phoneDevice.getUuids();  // Won't compile

Eclipse gives me: "The getUuids () method is undefined for the BluetoothDevice type." But look: http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getUuids ()

Also, I would like to know how the UUIDs are “split up” inside ParcelUuid []. If I ever manage to get there, how do I get the UUID from parcelUuid []? The documentation for Android bluetooth seems very poor in my opinion.

What a joke! Now I'm trying to get this out of intent, but it also gives: * "EXTRA_UUID cannot be resolved or is not a field" *:

intent.getParcelableExtra(BluetoothDevice.EXTRA_UUID); 
+5
5

getUuids() fetchUuidsWithSdp() android, 3. , :

Method method = phoneDevice.getClass().getMethod("getUuids", null);
ParcelUuid[] phoneUuids = (ParcelUuid[]) method.invoke(phoneDevice, null);
+5

// API 15 .

Broadcast Action: This intent is used to broadcast the UUID wrapped as a ParcelUuid of the remote device after it has been fetched. This intent is sent only when the UUIDs of the remote device are requested to be fetched using Service Discovery Protocol
    Always contains the extra field EXTRA_DEVICE
    Always contains the extra field EXTRA_UUID
    Requires BLUETOOTH to receive.
    Constant Value: "android.bluetooth.device.action.UUID"

// . . http://developer.android.com/sdk/compatibility-library.html

+2

, , UUID, BluetoothDevice API < 15. , API 15.

, docs BluetoothClass

BluetoothClass , ( , ), Bluetooth . SDP, RFCOMM- createRfcommSocketToServiceRecord (UUID) listenUsingRfcommWithServiceRecord (String, UUID).

, , , , . , , - Bluetooth.

, ( ), , (, SDP).

+1

UUID getUuids(). , .

byte[] (scanRecord), , UUID format, , UUID .

P/s: UUID format, .

// Put item into hash map
    // UUID from index 10 to 24 : 12233445566778899aabbccddeeff0
    StringBuilder mSbUUID = new StringBuilder();
    for (int i = 0; i < scanRecord.length; i++) {
        // UUID
        if (i >= 10 & i <= 24) {
            if (Integer.toHexString(
                    scanRecord[i]).contains("ffffff")) {
                mSbUUID.append(Integer.toHexString(scanRecord[i]).replace("ffffff", "") + "-");
            } else {
                mSbUUID.append(Integer.toHexString(scanRecord[i]) + "-");
            }
        }
    }
0
source

All Articles