Example usage for android.os ParcelUuid toString

List of usage examples for android.os ParcelUuid toString

Introduction

In this page you can find the example usage for android.os ParcelUuid toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of the ParcelUuid For example: 0000110B-0000-1000-8000-00805F9B34FB will be the return value.

Usage

From source file:Main.java

private static ArrayList<String> getDeviceServices(ArrayList<ParcelUuid> uuids) {
    ArrayList<String> result = new ArrayList<String>();
    for (ParcelUuid uuid : uuids) {
        String s = uuid.toString().toUpperCase();
        boolean found = false;
        for (Map.Entry<String, String> entry : uuidsDescriptions.entrySet()) {
            String key = entry.getKey().toUpperCase();
            String value = entry.getValue();

            if (s.startsWith("0000" + key)) {
                found = true;//w  ww  .  j  a  va 2 s  .  co  m
                result.add(value);
                break;
            }
        }
        if (!found) {
            String desc = "Unknown service UUID 0x" + s.substring(4, 8);
            result.add(desc);
        }
    }
    return result;
}

From source file:Main.java

public static ArrayList<ParcelUuid> getDeviceUuids(BluetoothDevice device) {
    ArrayList<ParcelUuid> result = new ArrayList<ParcelUuid>();

    try {//  ww w.j  a  va2s  . co  m
        Method method = device.getClass().getMethod("getUuids", null);
        ParcelUuid[] phoneUuids = (ParcelUuid[]) method.invoke(device, null);
        if (phoneUuids != null) {
            for (ParcelUuid uuid : phoneUuids) {
                if (D)
                    Log.d(TAG, device.getName() + ": " + uuid.toString());
                result.add(uuid);
            }
        }
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "getDeviceUuids() failed", e);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "getDeviceUuids() failed", e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "getDeviceUuids() failed", e);
    }

    return result;
}

From source file:org.chromium.ChromeBluetooth.java

private Collection<String> getUuidStringsFromDevice(BluetoothDevice device) {
    Set<String> uuidStrings = new HashSet<String>();
    ParcelUuid[] uuids = device.getUuids();
    if (uuids != null) {
        for (ParcelUuid uuid : uuids) {
            uuidStrings.add(uuid.toString());
        }/*from  ww w  . j  ava 2 s  . c  o m*/
    }
    return uuidStrings;
}

From source file:org.chromium.ChromeBluetooth.java

private Collection<String> getUuidStringsFromLeScanRecord(ScanRecord scanRecord) {
    Set<String> uuidStrings = new HashSet<String>();
    List<ParcelUuid> uuids = scanRecord.getServiceUuids();
    if (uuids != null) {
        for (ParcelUuid uuid : uuids) {
            uuidStrings.add(uuid.toString());
        }/*w  w  w .java  2  s . co m*/
    }
    return uuidStrings;
}