I need to parse and get the Value from :
Parcelable[] uuidExtra = intent.getParcelableArrayExtra("android.bluetooth.device.extra.UUID");
My goal is to get UUID from above Parcelable[]. How to achieve it?
Try something like this. It worked for me:
if(BluetoothDevice.ACTION_UUID.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Parcelable[] uuidExtra = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
for (int i=0; i<uuidExtra.length; i++) {
out.append("\n Device: " + device.getName() + ", " + device + ", Service: " + uuidExtra[i].toString());
}
Hope this helps!
You need to iterate over the Parcelable[], cast each Parcelable to ParcelUuid and use ParcelUuid.getUuid() to get the UUIDs. While you can use toString() on the Parcelables as in another answer, this will give you only a String representing the UUID, not an UUID Object.
Parcelable[] uuids = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
if (uuids != null) {
for (Parcelable parcelable : uuids) {
ParcelUuid parcelUuid = (ParcelUuid) parcelable;
UUID uuid = parcelUuid.getUuid();
Log.d("ParcelUuidTest", "uuid: " + uuid);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With