Поскольку я сейчас работаю над небольшой библиотекой bluetooth для Android, я пытаюсь получить все служебные uuids устройств, которые я обнаружил в своих окружающих.
Когда мой вещательный приемник получает намерение BluetoothDevice.ACTION_FOUND
, я извлекаю устройство и вызываю:
device.fetchUuidsWithSdp();
Это приведет к BluetoothDevice.ACTION_UUID
намерениям для каждого найденного устройства, и я обрабатываю их с одним и тем же получателем:
BluetoothDevice d = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Parcelable[] uuidExtra = intent.getParcelableArrayExtra(BluetoothDevice.EXTRA_UUID);
if(uuidExtra == null) {
Log.e(TAG, "UUID = null");
}
if(d != null && uuidExtra != null)
Log.d(TAG, d.getName() + ": " + uuidExtra.toString());
Дело в том, что uuidExtra
всегда null
.
Как я могу получить все UUID окружающих устройств?
EDIT:
Im работает над Nexus 7. Я попробовал код, который я нашел в Интернете, и это также дает мне NullPointerException: http://digitalhacksblog.blogspot.de/2012/05/android-example-bluetooth-discover-and.html
Спасибо.