Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

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 about 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!

asked Oct 28 '13 at 9:12
Ron
5,010954120
 
    
anyway, how could you know the UUID is for your bluetooth device @Ron?
– gumuruh
Jul 7 '14 at 7:23

1 Answer

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.

answered Oct 28 '13 at 20:36
Stefano S.
16413
 
    
I'm using SDK16 and it doesn't work for me. The uuids are null. Furthermore I'd like to have just my Bluetooth uuid. Do you know how to get this one?
– Ron
Oct 29 '13 at 8:08
    
There is an uuid for each
Bluetooth service exposed by the device; that's why you see multiple
uuids for the smartphone. I performed the tests using SDK on Nexus S
with Android 4.1.2 and Galaxy Nexus with Android 4.3. Which device did
you use?
– Stefano S.
Oct 29 '13 at 9:34
1  
Bluetooth has to be on. I tested on a Galaxy S2 with Android 4.1.2 and it worked, showing 12 UUIDs.
– Stefano S.
Oct 29 '13 at 13:10
2  
Ok, thats great so far -
thanks :) But how do I get THE uuid representing my phone? Or do I need
all of them for identifying my devide?
– Ron
Nov 4 '13 at 15:08
1  
@Ron, have you got what you
wanted? I also want to ask. Is it okay if i define my own UUID for two
different android devices to communicate each other? I mean, wouldn't it
be conflict if I use the same UUID for two different device?
– gumuruh
Jul 7 '14 at 7:24

Your Answer

stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device

stackoverflow.com/questions/19630810/android-get-bluetooth-uuid-for-this-device

Android - Get Bluetooth UUID for this device的更多相关文章

  1. android -- 蓝牙 bluetooth (三)搜索蓝牙

    接上篇打开蓝牙继续,来一起看下蓝牙搜索的流程,触发蓝牙搜索的条件形式上有两种,一是在蓝牙设置界面开启蓝牙会直接开始搜索,另一个是先打开蓝牙开关在进入蓝牙设置界面也会触发搜索,也可能还有其它触发方式,但 ...

  2. android -- 蓝牙 bluetooth (一) 入门

    前段时间在 网上看了一些关于android蓝牙的文章,发现大部分是基于老版本(4.1以前含4.1)的源码,虽然无碍了解蓝牙的基本原理和工作流程,但对着4.2.2的代码看起来总是有些遗憾.所以针对4.2 ...

  3. 深入了解Android蓝牙Bluetooth——《进阶篇》

    在 [深入了解Android蓝牙Bluetooth--<基础篇>](http://blog.csdn.net/androidstarjack/article/details/6046846 ...

  4. 深入了解Android蓝牙Bluetooth ——《总结篇》

    在我的上两篇博文中解说了有关android蓝牙的认识以及API的相关的介绍,蓝牙BLE的搜索,连接以及读取. 没有了解的童鞋们请參考: 深入了解Android蓝牙Bluetooth--<基础篇& ...

  5. ZT android -- 蓝牙 bluetooth (三)搜索蓝牙

    android -- 蓝牙 bluetooth (三)搜索蓝牙 分类: Android的原生应用分析 2013-05-31 22:03 2192人阅读 评论(8) 收藏 举报 bluetooth蓝牙s ...

  6. ZT android -- 蓝牙 bluetooth (一) 入门

    android -- 蓝牙 bluetooth (一) 入门 分类: Android的原生应用分析 2013-05-19 21:44 4543人阅读 评论(37) 收藏 举报 bluetooth4.2 ...

  7. 基于Android Classic Bluetooth的蓝牙聊天软件

    代码地址如下:http://www.demodashi.com/demo/12133.html BluetoothChat 基于Android Classic Bluetooth的蓝牙聊天软件,目前仅 ...

  8. android -- 蓝牙 bluetooth (五)接电话与听音乐

    1.蓝牙耳机接听电话         这个就对应HFP(Hands-freeProfile),Free your Hand,蓝牙的初衷之一.先来看这个功能的场景,手机来电,手机与蓝牙耳机已连接,这时会 ...

  9. 【转】Android:Bluetooth 的打开和关闭--不错

    原文网址:http://www.ifeegoo.com/android-turn-on-and-turn-off-bluetooth.html 摘要:Android 中打开和关闭 Bluetooth ...

随机推荐

  1. Asp.net中,点击GridView表头实现数据的排序

    一.实现该功能的基本工作. 1.  先添加一个GridView,取名为gvData. 2.  设置该控件的属性: 操作步骤如下 设置属性: 这4个属性,还要设置该控件AllowSorting=&quo ...

  2. form表单中的带有name的标签直接转JSON

    1. 将如下内容引入页面:比如说新建一个 a.js,然后在页面中引入a.js//将form表单序列化成json格式 $.fn.serializeObject = function () { var o ...

  3. javascript中的throttle和debounce

    throttle 我们这里说的throttle就是函数节流的意思.再说的通俗一点就是函数调用的频度控制器,是连续执行时间间隔控制.主要应用的场景比如: 1.鼠标移动,mousemove 事件2.DOM ...

  4. git分支--branch

    分支创建: $ git branch testing 显示分支: $ git branch iss53 * master testing 如果需要查看每一个分支的最后一次提交 $ git branch ...

  5. R语言笔记1--向量、数组、矩阵、数据框、列表

    注释:R语言是区分大小写的 1.向量 R语言中可以将各种向量赋值为一个变量,这种赋值操作符就是等号“=”,也可以使用“<-”. 1)产生向量 (1)函数c() 例如:x1=c(2,4,6,8,0 ...

  6. 缩放系列(二):所有子控件也随着缩放、手势缩放、多点触控layout

    下面是一个功能强大的改造的例子: 可以实现以下需求: 1.两个手指进行缩放布局 2.所有子控件也随着缩放, 3.子控件该有的功能不能丢失(像button有可被点击的功能,缩放后不能丢失该功能) 运行效 ...

  7. Linux SSH使用公钥私钥实现免登陆

    公钥和私钥(我是文盲,钥字之前都是读yao,这是多音字这里应该念yue),是成对出现的,一旦任何一个做了更改都会验证失败. 1.免登陆的实现:   使用下例中ssky-keygen和ssh-copy- ...

  8. postfix防垃圾邮件

    Postfix 2.x 打开/etc/postfix/main.cf文件,在其中增加如下的几行(如果相关的配置存在,就替换之): vi /etc/postfix/main.cf [...] smtpd ...

  9. sql关键字过滤C#方法

    /// <summary> ///SQL注入过滤 /// </summary> /// <param name="InText">要过滤的字符串 ...

  10. stdafx文件介绍

    MSDN介绍: These files are used to build a precompiled header file Projname.pch and a precompiled types ...