Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:
Android – Get Bluetooth UUID for this device
up vote 9 down vote favorite
7
|
I was browing Stack and the internet for a simple solution to get the UUID of the device I’m currently using. I stumbled over posts like this but none of them seemed to help me.
The doc tells me ab服务器托管网out this getUuids() function but when going through the doc for Android Bluetooth I end up having a BluetoothAdapter but I need a BluetoothDevice to execute this function.
So I need to know the following:
1) Is the function returning really the device UUID ? Because the name saids plural (服务器托管网getUuids )
2) How do I get an instance of this BluetoothDevice ?
Thanks!
android bluetooth uuid android-bluetooth
|
|
add a comment
|
shareimprove this question
|
asked Oct 28 ’13 at 9:12
Ron5,010954120
|
1 Answer
active oldest votes
up vote 13 down vote accepted
|
Using reflection you can invoke the hidden method getUuids() on the 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());
}
This is the result on a Nexus S:
UUID: 00001000-0000-1000-8000-00805f9b34fb
UUID: 00001001-0000-1000-8000-00805f9b34fb
UUID: 00001200-0000-1000-8000-00805f9b34fb
UUID: 0000110a-0000-1000-8000-00805f9b34fb
UUID: 0000110c-0000-1000-8000-00805f9b34fb
UUID: 00001112-0000-1000-8000-00805f9b34fb
UUID: 00001105-0000-1000-8000-00805f9b34fb
UUID: 0000111f-0000-1000-8000-00805f9b34fb
UUID: 0000112f-0000-1000-8000-00805f9b34fb
UUID: 00001116-0000-1000-8000-00805f9b34fb
where, for instance, 0000111f-0000-1000-8000-00805f9b34fb is for HandsfreeAudioGatewayServiceClass and 00001105-0000-1000-8000-00805f9b34fb is for OBEXObjectPushServiceClass . Actual availability of this method may depend on device and firmware version.
|
|
show 5 more comments
|
shareimprove this answer
|
answered Oct 28 ’13 at 20:36
Stefano S.16413
|
Your Answer
stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device
stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: 后端web开发之maven
介绍
依赖管理
这里写目录标题 介绍 创建maven项目 作用 作用1 作用2 作用3 简介 依赖管理 依赖配置 依赖传递 简介 依赖传递的可视化快捷键 排除依赖 依赖范围 生命周期 介绍 执行流程 介绍 创建maven项目 注意 maven属于项目一级,所以在创建项目的时候…