首页 > 其他分享 >Android - Get Bluetooth UUID for this device

Android - Get Bluetooth UUID for this device

时间:2023-09-05 16:36:35浏览次数:47  
标签:00805f9b34fb 0000 UUID uuid Bluetooth device Android 8000 1000

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

Android - Get Bluetooth UUID for this device_Android

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


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



标签:00805f9b34fb,0000,UUID,uuid,Bluetooth,device,Android,8000,1000
From: https://blog.51cto.com/u_5513510/7373661

相关文章

  • Android surfaceview的使用方式
    1.什么是surfaceviewsurfaceview内部机制和外部层次结构在安卓开发中,我们经常会遇到一些需要高性能、高帧率、高画质的应用场景,例如视频播放、游戏开发、相机预览等。这些场景中,我们需要直接操作图像数据,并且实时地显示到屏幕上。如果我们使用普通的view组件来实现这些功能,可能会......
  • android gridview画分割线
    dongyangzhangandroidgridview画分割线,如图:1。先上图:2.具体实现代码:publicclassLineGridViewextendsGridView{publicLineGridView(Contextcontext){super(context);//TODOAuto-generatedconstructorstub}publicLineGridView(Conte......
  • Android实时监听网络状态
    Android实时监听网络状态(1) 其实手机在网络方面的的监听也比较重要,有时候我们必须实时监控这个程序的实时网络状态,android在网络断开与连接的时候都会发出广播,我们通过接收系统的广播就可以实现网络的监听。1、添加访问网络和获取网络状态的权限<uses-permissionandroid:name="and......
  • Android总结篇系列:Android Service
    Android总结篇系列:AndroidService Service通常总是称之为“后台服务”,其中“后台”一词是相对于前台而言的,具体是指其本身的运行并不依赖于用户可视的UI界面,因此,从实际业务需求上来理解,Service的适用场景应该具备以下条件:1.并不依赖于用户可视的UI界面(当然,这一条其实也不是绝对的......
  • Android平台GB28181历史视音频文件检索规范探讨及技术实现
    技术背景我们在做Android平台GB28181设备接入侧模块的时候,特别是执法记录仪或类似场景,系统除了对常规的录像有要求,还需要能和GB28181平台侧交互,比如实现设备侧视音频文件检索、下载或回放。本文假定记录仪或相关设备已经完成录像,主要来探讨下设备视音频文件检索相关。规范解读先回......
  • Android并发编程高级面试题汇总(含详细解析 十七)
    Android并发编程高级面试题汇总最全最细面试题讲解持续更新中......
  • Android入门教程 | DialogFragment 的使用
    弹窗,是常见的一种提示方式。DialogFragment是在3.0时引入的,是一种特殊的Fragment,用于在Activity上展示一个模态的对话框。DialogFragment示例确定UI样式首先我们得知道做成什么样。一般来说简单的弹窗是一个标题,一端文字内容。或者带有一两个按钮。这里我们做一个有标题和文字......
  • 如果时光倒流,你还会选择做 Android 开发吗?
    最近看到知乎有人提出了这么一个问题引起了不少人的兴趣,我之前也是在6年前学的Android,自己也是深有感触,如果时光倒流我还是会选择做Android开发,很多人只是看到了现在Android的不景气,但是我那个时候开始学编程的时候,Android才是“顶流”。只要你会Android,也不说多好,也不怎么看学历......
  • dotnet 读 WPF 源代码笔记 GlyphRun 的 DeviceFontName 的功能是什么
    在WPF里面的GlyphRun里,有一个令人迷惑的DeviceFontName属性,似乎给这个属性传入什么值,结果都不会有变更。通过阅读源代码,可以了解到,这是一个没什么用途的属性。本文将告诉大家这个属性的细节逻辑在上一篇博客WPF简单聊聊如何使用DrawGlyphRun绘制文本里面就提到如何创......
  • 解决命令行提示“cannot create temp file for here-document: No space left on devi
    问题如题,出现“cannotcreatetempfileforhere-document:Nospaceleftondevice”,且部分应用出现故障,比如重启后Docker容器无法启动先使用df-h检查磁盘使用率,显示使用率50%还不到继续排查,使用lsof|grepdeleted 或lsof-w|grepdeleted检查是否存在未释放的已......