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. hdu_3562_B-number(记忆化搜索|数位DP)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3652 题意:给你一个n,为比n小的能整除13并数字中有13的数有多少个 题解:记忆化搜索:记dp[i] ...

  2. Self Numbers

    Self Numbers Time Limit : 20000/10000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Tota ...

  3. php的memcache和memcached扩展区别【转载】

    老生长谈的问题了.我这里就整理一下. memcache的文档在:http://pecl.php.net/package/memcache memcached的文档在:http://pecl.php.n ...

  4. 作为Web开发人员,我为什么喜欢Google Chrome浏览器

    来源: http://www.cnblogs.com/QLeelulu/archive/2011/08/28/2156402.html 在Google Chrome浏览器出来之前,我一直使用FireF ...

  5. UICollectionView之自定义Layout

    #import <UIKit/UIKit.h> @interface WQViewController : UIViewController - (id)initWithFrame:(CG ...

  6. Hibernate Tools for Eclipse安装

    声明:本文转载自 http://developer.51cto.com/art/200906/128067.htm Hibernate Tools for Eclipse Plugins 的安装和使用 ...

  7. 安装MSYS2过程遇到的问题及解决记录

    1.在安装结束后按照官方教程开始更新系统是遇到了如下的错误 could not open file /var/lib/pacman/sync/msys32.db: Unrecognized archi ...

  8. Form表单的post 和get跳转区别

    post是隐示请求 ----- 安全 get显示请求不安全,会在URL上显示路径和参数

  9. 最短路<dijk>

    题意: 有n个城市,有m条路,给出每条路的出发和结束的城市及长度,求从第一个城市到最后一个城市的最短路.按格式输出. power oj 2443 题解: 标准dijk算法. #include<c ...

  10. partial 函数

    函数的partial应用 函数在执行时,要带上所有必要的参数进行调用.但是,有时参数可以在函数被调用之前提前获知.这种情况下,一个函数有一个或多个参数预先就能用上,以便函数能用更少的参数进行调用. 例 ...